import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [a,b,k] <- map (read::String->Int) . words <$> getLine
  print $ (cdList a b)!!(k-1)

cdList a b = [x|let c = min a b, x<-[c,c-1..1], mod a x　==　0 && mod b x　==　0]