module Main where

import Control.Applicative

main :: IO ()
main = do
  [a, b, k] <- map read . words <$> getLine :: IO [Int]
  print $ (reverse [d | d <- [1..min a b], a `mod` d == 0 && b `mod` d == 0]) !! (k - 1)