import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.string; void main() { auto s = readln.split.map!(to!long); auto N = s[0]; auto D = s[1]; long[long] cnt; foreach (z; 1..N+1) foreach (w; 1..N+1) cnt[z*z-w*w] += 1; long ans = 0; foreach (x; 1..N+1) { foreach (y; 1..N+1) { if (D-x*x-y*y in cnt) { ans += cnt[D-x*x-y*y]; } } } ans.writeln; }