#include using namespace std; int N,M; int main() { ///freopen("triples.in","r",stdin); while(scanf("%d%d", &M, &N)==2) { int total = 0; for(int i = 0; i <= M; ++i) for(int j = i; j <= M; ++j) for(int k = j; k <= M; ++k) if(i*i + j*j == k*k) total++; total +=(M+1)*(N-2); printf("%d\n",total); } return 0; }