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