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