import collections N,D = map(int, input().split()) lszwD = collections.Counter() for i in range(1,N+1): for j in range(1,N+1): a = i**2-j**2+D if a >= 2: lszwD[a] += 1 ans = 0 for i in range(1,N+1): for j in range(i,N+1): if i == j: ans += lszwD[i**2+j**2] else: ans += lszwD[i**2+j**2]*2 print(ans)