solv a b k = go (min a b) (k-1) where
  go n k
    | a`mod`n==0 && b`mod`n==0
      = if k==0 then n else go (n-1) (k-1)
    | otherwise = go (n-1) k

main = do
  [a,b,k] <- map read . words <$> getLine
  print $ solv a b k
