N = int(input()) N2 = N * N ans = 0 a2 = set(x * x for x in range(1, N)) for x2 in a2: y2 = N2 - x2 if y2 in a2: ans += 1 print(ans)