import sys input = sys.stdin.readline x=int(input()) #x=5*10**5 import math L=math.floor(math.sqrt(x))#平方根を求める Primelist=[i for i in range(x+1)] Primelist[1]=0#1は素数でないので0にする. for i in Primelist: if i>L: break if i==0: continue for j in range(2*i,x+1,i): Primelist[j]=0 Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0] SP=set(Primes) ANS=0 for b in Primes: if b>math.sqrt(x): break for y in Primes: if y>b**2: break if b**2-y in SP: ANS+=1 print(ANS)