import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [n, m, p, q] = 12 * y + (length . takeWhile (<r)) ll
  where
    lpy = (12 + q) * m
    (y, r) = divMod n lpy
    ll = scanl (+) 0 $ zipWith (+) (replicate 12 m) (replicate (p - 1) 0 ++ replicate q m ++ replicate 12 0)