#4平方定理 N, D = map(int, input().split()) d = [0 for i in range(8*10**6+2)] e = [0 for i in range(8*10**6+2)] for i in range(1, N+1): for j in range(1, N+1): d[i**2+j**2] += 1 for i in range(1, N+1): for j in range(1, N+1): e[min(8*10**6+1, max(0,i**2-j**2+D))] += 1 ans = 0 for i in range(1, 8*10**6+1): ans += d[i]*e[i] print(ans)