import Control.Monad
import Data.Bool
import Data.List

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
readNInts = flip replicateM readInts

main :: IO ()
main = do
    [a, b, k] <- readInts
    print $ (!!(k - 1)) $ reverse $ nub $ intersect (factors a) (factors b)

factors :: Int -> [Int]
factors n = filter (\x -> n `mod` x == 0) [1..n]
