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

ans :: Int -> Int -> Int -> Int
ans a b k = (!! (k-1)) $ foldl (\acc k -> if mod g k == 0 then (div g k) : acc else acc) [] [g,g-1..1] where
  g = gcd a b