-- 2 variables
main = do
  (x:y:k:xs) <- map read . words <$> getLine
  putStrLn . show $ solve x y k 1

solve :: Int -> Int -> Int -> Int -> Int
solve x y 0 p = (p-1)
solve x y k p
  | x `mod` p == 0 && y `mod` p == 0 = solve x y (k-1) (p+1)
  | otherwise = solve x y k (p+1)
