main = getLine >>= print . solve . read . head . words solve :: Int -> Int solve n = n `div` f [2..n] (sqrt $ fromIntegral n) where f [] _ = n f (x : xs) mb | mod n x == 0 = x | fromIntegral x < mb = f [y | y <- xs, mod y x /= 0] mb | otherwise = foldl (\acc y -> if acc == n && mod n y == 0 then y else acc) n xs