import Control.Applicative

f a b c x y = do
  let cn = if (a + b) > c * 2 then min x y else 0
  let an = x - cn
  let bn = y - cn
  let can = if a > c * 2 && x > y then x - y else 0
  let cbn = if b > c * 2 && y > x then y - x else 0
  sum $ zipWith (*) [a, b, c] [max 0 $ an - (can * 2), max 0 $ bn - (cbn * 2), (cn + can + cbn) * 2]

main = do
  [a, b, c, x, y] <- map read <$> words <$> getLine :: IO [Int]
  print $ f a b c x y
