import Data.Ratio main = do [b1,b2,b3] <- map read . words <$> getLine print (ngs b1 b2 b3) ngs b1 b2 b3 = numerator (r * (fromIntegral b3) + d) where (r,d) = simeq b1 b2 b2 b3 simeq x y z w = (r,d) where r = (y-w) % (x-z) d = (fromIntegral w) - r * (fromIntegral z)