import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); boolean[] isNotPrime = new boolean[n * 3 + 1]; ArrayList primes = new ArrayList<>(); for (int i = 2; i < isNotPrime.length; i++) { if (!isNotPrime[i]) { primes.add(i); for (int j = 2; j * i < isNotPrime.length; j++) { isNotPrime[j * i] = true; } } } int[] counts = new int[n * 3 + 1]; counts[5] = 1; long ans = 0; for (int i = 2; primes.get(i) <= n; i++) { int x = primes.get(i); for (int j = i + 1; j < primes.size() && primes.get(j) < 3 * x; j++) { ans += counts[primes.get(j) - x]; } for (int j = 0; j < i; j++) { int y = primes.get(j); counts[x + y]++; } } System.out.println(ans); } }