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 = let g = gcd a b in kthdiv k g g

kthdiv :: Int -> Int -> Int -> Int
kthdiv k g cur = if g `mod` cur == 0
    then case k of
        1  -> cur
        k' -> kthdiv (k' - 1) g (cur - 1)
    else kthdiv k g (cur - 1)
