N, D = map( int, input().split()) left = [0]*(8*(10**6)+1) right = [0]*(9*(10**6)+1) for i in range(1, N+1): for j in range(1, N+1): left[i**2 + j**2] += 1 for i in range(1, N+1): for j in range(1, N+1): right[i**2 - j**2 + D+4*10**6] += 1 ans = 0 for i in range(1, 4*10**6+1): ans += left[i]*right[i+4*10**6] print(ans)