#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define dbg(x) (cout<<#x<<" = "<<(x)<<'\n') #ifdef HOME const string inputFile = "input.txt"; const string outputFile = "output.txt"; #else const string problemName = ""; const string inputFile = problemName + ".in"; const string outputFile = problemName + ".out"; #endif typedef long long int lld; typedef pair PII; typedef pair PIL; typedef pair PLI; typedef pair PLL; const int INF = (1LL << 31) - 1; const lld LINF = (1LL << 62) - 1; const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1}; const int MOD = (int)(1e9) + 7; const int NMAX = 100000 + 5; const int MMAX = 100000 + 5; const int KMAX = 100000 + 5; const int PMAX = 100000 + 5; const int LMAX = 100000 + 5; const int VMAX = 100000 + 5; int main() { int i, j, k, n, m, cnt = 0; #ifdef HOME freopen(inputFile.c_str(), "r", stdin); freopen(outputFile.c_str(), "w", stdout); #endif while(scanf("%d%d", &m, &n) + 1) { cnt = 0; for(i = 0; i <= m; i++) for(j = i; j <= m; j++) for(k = j; k <= m; k++) if(i * i + j * j == k * k) cnt++; cnt += (n - 2) * (m + 1); printf("%d\n", cnt); } return 0; }