#include using namespace std; int N,M; long long put(long long a,long long b) { long long x1 = a,x2 = 1; if(b == 0)return 1; if(b == 1) return a; while(b > 1) if(b&1) { x2 = x1 * x2; b^= 1; } else { x1 = x1 * x1; b >>= 1; } return x1 * x2; } int main() { ///freopen("triples.in","r",stdin); scanf("%d%d",&M,&N); long long total = 0; for(int x = 0; x <= M; ++x) for(int y = x; y <= M; ++y) for(int z = y; z <= M; ++z) if(x*x + y*y == z*z) total ++; total += (M + 1)*(N-2); printf("%lld\n",total); return 0; }