import itertools n, d = map(int, input().split()) count = 0 r = range(1, n + 1) for x, y, z in itertools.product(r, r, r): s = x*x + y*y + z*z - d if (s <= 0): continue w = int(s ** 0.5 + 0.5) if (w <= n and w*w == s): # print(x,y,z,w) count += 1 print(count)