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