import math from math import sqrt import sys from collections import deque, defaultdict from heapq import heappop,heappush from copy import deepcopy INF=10**18 MOD=10**9+7 MAX=10**5+7 isp=[1]*MAX*5*2 def eratos(n): global isp isp[0]=isp[1]=0 for i in range(2, int(sqrt(n)+1)): if isp[i]==0: continue for j in range(i+i, n+1, i): isp[j]=0 def main(): global isp N=int(input()) eratos(N*2) ans=0 for r in range(int(sqrt(N*2)+1)): if isp[r]==0: continue for p in range(N+1): if r*r-p>0 and isp[p] and isp[r*r-p]: ans+=1 print(ans) if __name__=='__main__': main()