import Control.Monad

type Degree = Int
type Sec   = Int

solver :: Int -> Int -> Int -> Int -> Int -> Int
solver a b c d e
  | a < 0    = heathen (-a) c + d + heathen b e
  | a > 0    = heathen (b-a) e
  |otherwise = d + heathen b e

heathen :: Degree -> Sec -> Sec
heathen d s = d * s


main :: IO()
main = do
  contents <- replicateM 5 getLine
  let (a:b:c:d:e:_) = map (read :: String -> Int) contents
  print $ solver a b c d e