from collections import defaultdict N, D = map(int, input().split()) V = defaultdict(int) for y in range(1, N + 1): for z in range(1, N + 1): V[y**2 + z**2] += 1 ans = 0 for w in range(1, N + 1): for x in range(1, N + 1): E = w**2 + D - x**2 ans += V[E] print(ans)