#include using namespace std; int N,M; 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; }