let () =
  let rec prime n m = if n = m then true else if n mod m = 0 then false else prime n (m+1) in
  let rec check n m = if prime n 2 then n else if n = m then n else check (n+1) m  in
  let n = read_int () in
  Printf.printf "%d\n" (check n (n*2))