def primes(N): #N = 5 * (10 ** 5) res = [] isprime = [True] * (N + 1) isprime[0] = isprime[1] = False for i in range(2, N + 1): if isprime[i]: res.append(i) for j in range(i * 2, N + 1, i): isprime[j] = False return res N = int(input()) P = primes(N) #print(len(P)) S = set([r * r for r in P]) ans = 0 for q in P: q2 = q + 2 if q2 in S: ans += 1 print(ans * 2 - 1)