import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList primes = new ArrayList<>(); for (int i = 3; i <= 3 * n; i += 2) { if (isPrime(i, primes)) { primes.add(i); } } long total = 0; int[] counts = new int[3 * n]; for (int i = 2; i < primes.size(); i++) { int c = primes.get(i); if (c > n) { break; } int b = primes.get(i - 1); for (int j = 0; j < i - 1; j++) { int a = primes.get(j); counts[a + b]++; } for (int j = i + 1; j < primes.size(); j++ ) { int sum = primes.get(j); if (sum - c > 0) { total += counts[sum - c]; } } } System.out.println(total); } static boolean isPrime(int x, ArrayList primes) { for (int y : primes) { if (y > Math.sqrt(x)) { break; } if (x % y == 0) { return false; } } return true; } }