import java.util.ArrayList; import java.util.Scanner; public class DifferentSosu { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); s.close(); ArrayList p = new ArrayList<>(); p.add(2); for(int i = 3;i <= N;i++){ int a = 1; for(int j = 0;j < p.size();j++){ if(i % p.get(j) == 0){ a = 0; break; } } if(a == 1){ p.add(i); } } //System.out.println(p); int[] root = new int[N+1]; root[0] = 0; root[1] = -1; for(int i:p){ for(int j = N;j >= 0;j--){ if(j-i >= 0&&root[j-i] != -1){ root[j] = Math.max(root[j-i] + 1, root[j]); if(root[j] == 1 && !p.contains(j)){ root[j] = -1; } } } /*for(int k:root){ System.out.print(k + " "); } System.out.println();*/ } System.out.println(root[N]); //System.out.println(t.get(N)); } }