from collections import defaultdict n, d = map(int, input().split()) counter = defaultdict(int) for w in range(1, n + 1): for z in range(1, n + 1): counter[w**2 - z**2] += 1 ans = 0 for x in range(1, n + 1): for y in range(1, n + 1): res = x**2 + y**2 - d ans += counter[res] print(ans)