n = int(input()) import math def is_prime(n): if n == 1: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True prime = [] for i in range(1, n+1): if is_prime(i): prime.append(i) if n == 1: print(0) else: ans = 1 for r in prime[1:]: if r**2-2 > n: break if r**2-2 in prime: ans += 2 print(ans)