// yukicoder: No.800 四平方定理 // 2019.4.13 bal4u // ハッシュテーブル x^2 + y^2 = w^2 + D - z^2 #include //// 高速入力 #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() // 非負整数の入力 { int n = 0, c = gc(); do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0'); return n; } //// ハッシュテーブル #define HASHSIZ 19999999 //9999991 typedef struct { int s, cnt; } HASH; HASH hash[HASHSIZ+5], *hashend = hash + HASHSIZ; int lookup(int s) { HASH *p = hash + s % HASHSIZ; while (p->s) { if (p->s == s) return p->cnt; if (++p == hashend) p = hash; } return 0; } void insert(int s) { HASH *p = hash + s % HASHSIZ; while (p->s) { if (p->s == s) { p->cnt++; return; } if (++p == hashend) p = hash; } p->s = s, p->cnt = 1; } #define MAX 2000 int n2[MAX+5]; int main() { int i, k, N, D, x, y, z, w, ans; for (i = 0; i < MAX; i++) { n2[i+1] = n2[i] + (i<<1) + 1; } N = in(), D = in(); for (x = 1; x <= N; x++) for (y = 1; y <= N; y++) { insert(n2[x] + n2[y]); } ans = 0; for (w = 1; w <= N; w++) { k = D + n2[w]; for (z = 1; z <= N; z++) { if (k - n2[z] > 1) ans += lookup(k - n2[z]); } } printf("%d\n", ans); return 0; }