import java.io.PrintWriter import java.lang.Math.abs import java.math.BigDecimal import java.math.BigInteger import java.util.* import kotlin.math.max import kotlin.math.min @JvmField val INPUT = System.`in` @JvmField val OUTPUT = System.out @JvmField val cin = INPUT.bufferedReader() fun readLine(): String? = cin.readLine() fun readLn() = cin.readLine()!! @JvmField var _tokenizer: StringTokenizer = StringTokenizer("") fun read(): String { while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(cin.readLine() ?: return "", " ") return _tokenizer.nextToken() } fun readInt() = read().toInt() fun readDouble() = read().toDouble() fun readLong() = read().toLong() fun readStrings(n: Int) = List(n) { read() } fun readLines(n: Int) = List(n) { readLn() } fun readInts(n: Int) = List(n) { read().toInt() } fun readIntArray(n: Int) = IntArray(n) { read().toInt() } fun readDoubles(n: Int) = List(n) { read().toDouble() } fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() } fun readLongs(n: Int) = List(n) { read().toLong() } fun readLongArray(n: Int) = LongArray(n) { read().toLong() } @JvmField val cout = PrintWriter(OUTPUT, false) fun main(args: Array) { val t = read().toBigInteger() if(t <= 25.toBigInteger()){ val tt = t.toInt() cout.println( when(tt) { 4 -> 3 6 -> 5 in arrayOf(8, 9, 10, 15, 16, 22) -> 7 12 -> 11 14 -> 13 20 -> 19 21 -> 19 24 -> 23 25 -> 23 else -> 8 }) }else { cout.println(if(t.minus(8.toBigInteger()).isProbablePrime(100)) 14 else 8) } cout.flush() }