N,D = map(int,input().split()) from collections import defaultdict # x^2 + y^2で作れる数を全列挙 XY = [0] * ((N ** 2) * 2 + 1) for x in range(1, N + 1): for y in range(1, N + 1): XY[x ** 2 + y ** 2] += 1 ans = 0 for z in range(1, N + 1): for w in range(1, N + 1): target = D - (z ** 2 - w ** 2) if 0 <= target <= (N ** 2) * 2: ans += XY[target] print(ans)