import sys sys.setrecursionlimit(10**6) def MI(): return map(int, sys.stdin.buffer.readline().split()) n, d = MI() cnt = [0]*(2*n*n+1) for x in range(1, n+1): for y in range(1, n+1): cnt[x*x+y*y] += 1 ans = 0 for w in range(1, n+1): s = w*w+d for z in range(1, n+1): t = s-z*z if t < 0: break ans += cnt[t] print(ans)