N, D = map(int, input().split()) ans = 0 cnt1 = [0] * (2*N**2 + 10) cnt2 = [0] * (2*N**2 + 10) L = len(cnt1) for x in range(1, N+1): for y in range(1, N+1): v = x**2+y**2 if 0 <= v < L: cnt1[v] += 1 for z in range(1, N+1): for w in range(1, N+1): v = D + w**2 - z**2 if 0 <= v < L: cnt2[v] += 1 ans = 0 for i in range(L): ans += cnt1[i] * cnt2[i] print(ans)