N, D = map(int, input().split()) NN = N**2 p, n = [0]*(2*NN+1), [0]*(2*NN+1) for i in range(1, N+1): for j in range(1, N+1): p[i**2 + j**2] += 1 a = i**2 - j**2 + D if 0 <= a <= 2*NN: n[a] += 1 res = 0 for i in range(2*NN+1): res += p[i]*n[i] print(res)