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