import java.io.*; class Prime { boolean[] is_prime; int[] primes; void setPrime(int n) { int i, j; is_prime = new boolean[n + 1]; is_prime[0] = false; is_prime[1] = false; for (i = 2; i <= n; i++) { is_prime[i] = true; } int cnt = 0; for (i = 2; i <= n; i++) { if (is_prime[i]) { for (j = i * 2; j <= n; j += i) { is_prime[j] = false; } cnt++; } } primes = new int[cnt]; int id = 0; for (i = 2; i <= n; i++) { if (!is_prime[i]) continue; primes[id] = i; id++; } } int[] getPrimes() { return primes; } boolean isPrime(int x) { return is_prime[x]; } }; class Solver { int[] cnts; public static void main(String[] args) { Solver solver = new Solver(); solver.solve(); } void solve() { int n = readInt(); Prime prime = new Prime(); prime.setPrime(3 * n); int[] primes = prime.getPrimes(); initCnts(3 * n); cnts[primes[0] + primes[1]]++; long ans = 0; int max_exist = primes[0] + primes[1]; for (int i = 2; i < primes.length && primes[i] <= n; i++) { for (int j = i + 1; j < primes.length && primes[j] - primes[i] <= max_exist; j++) { ans += cnts[primes[j] - primes[i]]; } for (int j = 0; j < i; j++) { cnts[primes[i] + primes[j]]++; } max_exist = primes[i] + primes[i - 1]; } System.out.println(ans); } int readInt() { try { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); String s = r.readLine(); return Integer.parseInt(s); } catch (IOException e) { return 0; } } void initCnts(int n) { cnts = new int[n + 1]; for (int i = 0; i <= n; i++) cnts[i] = 0; } }