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