import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; import java.util.TreeSet; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); boolean[] is_prime = new boolean[N + 1]; Arrays.fill(is_prime, true); is_prime[0] = is_prime[1] = false; ArrayList primes = new ArrayList(); for(int i = 2; i <= N; i++){ if(!is_prime[i]){ continue; } primes.add(i); for(int j = i * 2; j <= N; j += i){ is_prime[j] = false; } } int[] times = new int[N + 1]; Arrays.fill(times, -1); times[0] = 0; for(final int p : primes){ for(int v = N - p; v >= 0; v--){ if(times[v] < 0){ continue; } times[v + p] = Math.max(times[v + p], times[v] + 1); } } System.out.println(times[N]); } }