from collections import Counter N, D = map(int, input().split()) xpy = [] for x in range(1, N + 1): for y in range(1, N + 1): xpy.append(x**2 + y**2) wmz = [] for w in range(1, N + 1): for z in range(1, N + 1): wmz.append(w**2 - z**2) cnt = Counter(wmz) ans = 0 for xy in xpy: ans += cnt.get(xy - D, 0) print(ans)