import           Control.Monad
import           Control.Applicative
import           Data.Ord
import           Data.List
import qualified Data.Vector                   as V
import           Data.Array.IO

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

  print
    $  ((reverse . sort)
         [ i | i <- [1 .. max a b], a `mod` i == 0 && b `mod` i == 0 ]
       )
    !! (c - 1)