import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); BigInteger n = new BigInteger(sc.next()); int[] num100 = {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.intValue() < 100){ System.out.println(num100[n.intValue()-1]); }else{ if(n.mod(BigInteger.valueOf(8)).intValue() != 1){ System.out.println(8); }else{ BigInteger m = n.subtract(BigInteger.valueOf(8)); if(m.isProbablePrime(50)){ System.out.println(14); }else{ System.out.println(8); } } } } }