N = int(input()) def eratosthenes(n): if n < 2: return [] is_primes = [True] * (n + 1) for x in range(2, int(n ** 0.5 + 1) + 1): if is_primes[x]: for mx in range(2 * x, n + 1, x): is_primes[mx] = False return [i for i in range(2, n + 1) if is_primes[i]] primes = eratosthenes(N) prime_set = set(primes) ans = 0 for r in primes: if r ** 2 > 2 * N: break for p in primes: q = r ** 2 - p if q in prime_set: ans += 1 print(ans)