ADD = 4*10**6 def main(): N, D = (int(i) for i in input().split()) cA = [0]*(2*ADD+1) for x in range(1, N+1): for y in range(1, N+1): v = x**2 + y**2 + ADD if 2 <= v <= 2*ADD: cA[v] += 1 cB = [0]*(2*ADD+1) for z in range(1, N+1): for w in range(1, N+1): v = w**2 - z**2 + D + ADD if 2 <= v <= 2*ADD: cB[v] += 1 ans = 0 for a, b in zip(cA, cB): ans += a*b print(ans) if __name__ == '__main__': main()