import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [a, b, k] = let g = gcd a b
                  in (f g g) !! (k - 1)
  where
    f x y
      | y == 0 = []
      | x `mod` y == 0 = y : f x (y - 1)
      | otherwise = f x (y - 1)
