def main(): N, D = (int(i) for i in input().split()) A = [] for x in range(1, N+1): for y in range(1, N+1): A.append(x**2 + y**2) B = [] for z in range(1, N+1): for w in range(1, N+1): B.append(z**2 - w**2) from collections import Counter ans = 0 cB = Counter(B) for a in A: ans += cB[D-a] print(ans) if __name__ == '__main__': main()