{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

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

solve :: Int -> Int -> Int -> Int
solve a b k = [i | i <- reverse [1 .. min a b], divisible a b i] !! (k - 1)

divisible :: Int -> Int -> Int -> Bool
divisible a b i = a `mod` i == 0 && b `mod` i == 0
