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