import random def MillerRabin(q, k = 50): ''' 素数判定の ミラー・ラビン テスト 以下のコードをもとに作成。 http://d.hatena.ne.jp/pashango_p/20090704/1246692091 ''' if q == 2: return True if q == 1 or not (q & 1): return False d = (q - 1) >> 1 while not (d & 1): d >>= 1 for i in range(k): a = random.randint(1, q - 1) t = d y = pow(a, t, q) while t != q - 1 and y != 1 and y != q - 1: y = pow(y, 2, q) t <<= 1 if y != q - 1 and not (t & 1): return False return True def solve(N): dic = {4:3, 6:5, 8:7, 9:7, 10:7, 12:11, 14:13, 15:7, 16:7, 18:8, 20:19, 21:19, 22:7, 24:23, 25:23, 26:8} if N in dic: return dic[N] M = N - 8 if MillerRabin(M): return 14 return 8 N = int(input()) print(solve(N))