N = int(input()) P = list(range(N+1)) P[0] = -1 P[1] = -1 for i in range(2,N+1): if i*i>N:break for j in range(i*i,N+1,i): P[j] = P[i] Q = [] for i in range(2,N+1): if P[i]==i: Q.append(i) S = [] for r in Q: if r**2>2*N:break S.append(r**2) ans = 0 for z in S: for p in Q: if N>=z-p>0 and P[z-p]==z-p: ans += 1 print(ans)