require 'prime' h = { 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 } n = gets.to_i if h[n] puts h[n] elsif (n-1)%8 == 0 && Prime.prime?(n-8) puts 14 else puts 8 end