from collections import defaultdict N, D = map(int, input().split()) r1 = [] r2 = [] d1 = defaultdict(list) d2 = defaultdict(list) ans = 0 for x in range(1, N + 1): for y in range(1, N + 1): s = x**2 + y**2 d1[str(s)].append([x, y]) for z in range(1, N + 1): for w in range(1, N + 1): if w**2 - z**2 + D > 1: s = d1.get(str(w**2 - z**2 + D)) if s: ans += len(s) print(ans)