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 + 1]; int[] counts = new int[n + 1]; Arrays.fill(counts, -1); counts[0] = 0; for (int i = 2; i <= n; i++) { if (!isNotPrime[i]) { for (int j = 2; j * i <= n; j++) { isNotPrime[j * i] = true; } for (int j = n; j - i >= 0; j--) { if (counts[j - i] == -1) { continue; } counts[j] = Math.max(counts[j], counts[j - i] + 1); } } } System.out.println(counts[n]); } }