N,D = map(int,input().split()) from collections import defaultdict left = defaultdict(int) for x in range(1, N + 1): for y in range(1, N + 1): left[x**2 + y**2] += 1 right = defaultdict(int) for w in range(1, N + 1): for z in range(1, N + 1): val = w**2 - z**2 + D if val < 0: break right[w**2 - z**2 + D] += 1 ans = 0 for key, value in left.items(): if key in right: ans += right[key] * value print(ans)