main = do
    [a,b,k] <- (fmap read . words) <$> getLine :: IO [Int]
    print $ (reverse $ factors (gcd a b))!!(k-1)

divides :: Int -> Int -> Bool
n `divides` m = m `mod` n == 0

factors :: Int -> [Int]
factors n = [ y | y <- [1..n], y `divides` n ]