import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n == 1) { System.out.println(0); return; } TreeSet primes = new TreeSet<>(); for (int i = 2; i <= n; i++) { if (isPrime(primes, i)) { primes.add(i); } } long total = -1; for (int x : primes) { if (primes.contains(getNum(x + 2))) { total += 2; } } System.out.println(total); } static int getNum(int x) { int ans = (int)Math.sqrt(x); if (ans * ans == x) { return ans; } else { return 0; } } static boolean isPrime(TreeSet primes, int x) { for (int y : primes) { if (y * y > x) { break; } if (x % y == 0) { return false; } } return true; } }