N=int(input()) X=[i*i for i in range(1,N+1)] M=N*N S=set() ANS=0 for i in range(N): S.add(X[i]) for i in range(N): if M-X[i] in S: ANS+=1 print(ANS)