import Control.Applicative

inputs = fmap (read :: String -> Int) . words <$> getLine

ruu lst = [n | n <- [0..c*w] ,  (r*(n-1) + r0) < c*w]
    where
        r0 = lst !! 0
        w  = lst !! 1
        c  = lst !! 2
        r  = lst !! 3

solve lst = maximum $ 0 : lst
main = inputs >>= \x -> if (x !! 2) /= 0 then (print $ solve $ ruu x) >> main else do return ()