#include #include using namespace std; int main() { int N ,D,a,b,c,d,s; cin >> N >> D; s = 0; a = 1; b = 1; c = 1; d = 1; while (a <= N) { b = a; while (b <= N) { c = b; while (c <= N) { while(d<=N){ if (a*a + b * b + c * c - d * d == D) { if (a != b && b != c && c != a) { s = s + 6; } else if (a==b&&b==c) { s++; } else { s=s+3; } } d++; }d = 1;c++; }c = 1;b++; }b = 1;a++; } cout << s << endl; return 0; }