module Main where

import qualified Data.Vector as V 
import qualified Data.Map as M
import Control.Monad
import Data.Maybe
readint :: IO Int
readint = read <$> getLine

readvec :: IO [Int]
readvec = (fmap read . words) <$> getLine

main :: IO()
main = do
  [a,b,k] <- readvec
  l <- forM [1..100] $ \i -> do
    if a `mod` i == 0 && b `mod` i == 0
       then pure $ Just i
       else pure Nothing
  -- print $ catMaybes l
  print $ (reverse $ catMaybes l) !! (k-1)

