main = do [a,b,x,y] <- getLine >>= return . map read . words print $ if x * b / a > y then y + y * a / b else x + x * b / a