import Data.List main = getLine >>= print . tea . map read . words tea [a,b,x,y] = min (x + (b/a) * x) (y + (a/b) * y)