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); } } int[][] root = new int[N+1][2]; root[1][0] = -1; for(int i = 2;i <= N;i++){ for(int q:p){ if(i-q < 0){ root[i][0] = -1; break; }else if(root[i-q][0] != -1 && root[i-q][1] < q){ root[i][0] += root[i-q][0] + 1; root[i][1] = q; break; } } //System.out.println(root[i][0] + " " + root[i][1]); } if(root[N][0] == 0){ root[N][0] = -1; } System.out.println(root[N][0]); } }