main :: IO ()
main = do
    [a, b, k] <- fmap (map read . words) getLine :: IO [Int]
    print $ solve a b k

solve :: Int -> Int -> Int -> Int
solve a b k =
    (filter (\x -> (a `mod` x == 0) && (b `mod` x == 0)) [100, 99 .. 1])
        !! (k - 1)
