from collections import * N, D = map(int, input().split()) S = defaultdict(int) for i in range(1, N + 1): for j in range(1, N + 1): S[D + i * i - j * j] += 1 ans = 0 for i in range(1, N + 1): for j in range(1, N + 1): ans += S[i * i + j * j] print(ans)