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