import Data.List
import Data.Char

main::IO ()
main = do
    [a,b,t] <- map read . words <$> getLine
    let line = zip [a,a*2..] [b,b*2..]
    let ans = snd $ head $ dropWhile (\(x,y) -> x<=t) line 
    print (ans-b)