import Control.Monad
import Control.Applicative

solve i a b 1
    |(mod a i ==0)&&(mod b i ==0) = i
    |otherwise = solve (i-1) a b 1

solve i a b n
    |(mod a i ==0)&&(mod b i ==0) = solve (i-1) a b (n-1)
    |otherwise = solve (i-1) a b n



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