import Data.List

main :: IO ()
main = do
    [a,b,k] <- map read . words <$> getLine :: IO [Int]
    let g = gcd a b
        a' = [ i | i <- [1..g], (a `mod` i) == 0]
        b' = [ i | i <- [1..g], (b `mod` i) == 0]
        c  = intersect a' b'
    print $ c !! (length c - k)
