import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); boolean[] isNotPrime = new boolean[n * 3 + 1]; ArrayList primes = new ArrayList<>(); for (int i = 3; i <= n * 3; i += 2) { if (isNotPrime[i]) { continue; } for (int j = 3; j * i <= n * 3; j += 2) { isNotPrime[j * i] = true; } if (i <= n) { primes.add(i); } } long ans = 0; int[] counts = new int[n * 2 + 1]; int prev = 0; for (int x : primes) { for (int y : primes) { if (y >= prev) { break; } counts[y + prev]++; } for (int i = x * 2 - 6; i >= 8; i -= 2) { if (!isNotPrime[i + x]) { ans += counts[i]; } } prev = x; } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }