import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline def from_read(): return [int(x) for x in read().splitlines()] def from_readline(): return [int(x) for x in readline().split()] def read_matrix(N, M): matrix = [None for i in range(N)] for i in range(N): matrix[i] = from_readline() return matrix def solve(N): square = {n*n for n in range(1, N)} res = 0 N *= N for s in square: if N - s in square: res += 1 return res def main(): N = int(readline()) print(solve(N)) if __name__ == "__main__": main()