from itertools import chain def prime_set(N): """ Nまでの素数のsetを返す """ if N < 4: return ({}, {}, {2}, {2, 3})[N] Nsq = int(N ** 0.5 + 0.5) + 1 primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6))) for i in range(5, Nsq, 2): if i in primes: primes -= set(range(i * i, N + 1, i * 2)) return primes N = int(input()) R = [] prime = prime_set(N) ans = 0 for p in prime: q = p * p - 2 if q in prime: if q != 2: ans += 1 ans += 1 print(ans)