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 y == x: cnt[x**2+y**2] += 1 else: cnt[x**2+y**2] += 2 ans = 0 for w in range(1, n+1): tmp = w**2+d for z in range(1, min(tmp, n+1)): ans += cnt[tmp - z**2] print(ans)