let is_composite_number m = let rec inner n = if n mod m = 0 then true else if n >= m then false else inner (n + 1) in if m = 2 then false else inner 2 let solve n = let rec inner m = if n - 100 <= m && m <= n + 100 then begin if is_composite_number m then m else inner (m + 1) end else assert false in print_int @@ inner (n - 100) let _ = let n = int_of_string @@ read_line () in solve n