{-# LANGUAGE  ViewPatterns #-}
module Main (main) where

main :: IO ()
main = interact solve

solve :: String -> String
solve (map (read :: String -> Int) . words ->  [a, b, c, x, y]) = show $ loop 0 0 0
  where loop ca cb  tot | ca < x && cb < y = loop (ca + 1) (cb + 1) $ if c * 2 <= a + b
                                                                      then tot + c * 2
                                                                      else tot + a + b
                        | ca < x           = if c * 2 <= a
                                             then loop (ca + 1) (cb + 1) (tot + c * 2)
                                             else loop (ca + 1) cb (tot + a)
                        | cb < y           = if c * 2 <= b
                                             then loop (ca + 1) (cb + 1) (tot + c * 2)
                                             else loop ca (cb + 1) (tot + b)
                        | otherwise        = tot
