def era(n): is_prime = [True]*(n+1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5)+1): if not is_prime[i]: continue for j in range(2*i, n+1, i): is_prime[j] = False return is_prime, [i for i in range(n+1) if is_prime[i]] N = int(input()) is_prime, primes = era(N) ans = 0 for r in primes: if r**2>2*N: break for p in primes: if r**2-p<0: break if r**2-p<=N and is_prime[r**2-p]: ans += 1 print(ans)