solve a b = [x | x <- [1..(min a b) + 1], mod a x == 0 && mod b x == 0]

parseInput input = map read $ words input :: [Int]

main = do
    line <- getLine
    let [a, b, k] = parseInput line
    let lst = reverse(solve a b)
    print $ lst !! (k - 1)
