import itertools n, d = map(int, input().split()) count = 0 for x in range(1, n + 1): yMax = min(max(1, x*x + 1 + 1 - d), n) for y in range(1, yMax + 1): zMax = min(max(1, x*x + y*y + 1 - d), n) for z in range(1, zMax + 1): 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): count += 1 print(count)