import java.util.*; import java.math.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger N = new BigInteger(sc.next()); int[] ans = {1,1,1,1,3,1,5,1,7,7,7,1,11,1,13,7,7,1,8,1,19,19,7,1,23,23,8,8,8,1,8,1,8,8,8,8,8,1,8,8,8,1,8,1,8,8,8,1,8,14,8,8,8,1,8,8,8,8,8,1,8,1,8,8,8,8,8,1,8,8,8,1,8,1,8,8,8,8,8,1,8,14,8,1,8,8,8,8,8,1,8,8,8,8,8,8,8,1,8,8}; if (N.compareTo(BigInteger.valueOf(100)) < 0) { int n = N.intValue(); System.out.println(ans[n]); } else { if (N.mod(BigInteger.valueOf(8)).intValue() != 1) { System.out.println(8); } else if (!N.subtract(BigInteger.valueOf(8)).isProbablePrime(30)) { System.out.println(8); } else { System.out.println(14); } } } }