main = do
--    s <- map read . words <$> getLine ::IO [Int] 
    n <- readLn ::IO Int
    print $ solve n

solve :: Int -> Int
solve n
    | n < 3 = n
    | query n == [] = solve (n-1)
    | sum (query n) == 0 = n
    | otherwise = solve (n-1)


query :: Int -> [Int]
query n = map (`mod` 2) $ filter (\x -> n `mod` x ==0)[2..n-1] 


