open Scanf
open Printf

let ($) f x = f x
let scanIntlist n = let list = ref [] in
  for i = 1 to n do
    list := (scanf (if i < n then "%d " else "%d") (fun x -> x))::!list
  done; List.rev !list
    
let string2charlist s = let rec proc i res =
                          try proc (i+1) $ s.[i]::res
                          with Invalid_argument _ -> res
  in List.rev $ proc 0 []
       
let minInt l = let rec proc l res = match l with
      [] -> res
    | x::xs -> if x < res then proc xs x else proc xs res
  in if l == [] then raise $ Failure "null list" else proc l max_int

let maxInt l = let rec proc l res = match l with
      [] -> res
    | x::xs -> if x > res then proc xs x else proc xs res
  in if l == [] then raise $ Failure "null list" else proc l min_int

let rec listSum = function
    [] -> 0
  | x::xs -> x+listSum xs;;

let rec quick_sort = function
    ([] | [_]) as l -> l
  | pivot :: rest ->
     let rec partition left right = function
	 [] -> (quick_sort left) @ (pivot :: quick_sort right)
       | y :: ys -> if pivot < y then partition left (y :: right) ys
                    else partition (y :: left) right ys
     in partition [] [] rest


let calc a b c x y = let p1 = a*x + b*y in
  let p2 = if x < y then c*2*x + b*(y-x) else c*2*y + a*(x-y) in
  let p3 = if x < y then c*2*y else c*2*x in
  minInt [p1;p2;p3];;

scanf "%d %d %d %d %d" $ fun a b c x y -> print_int $ calc a b c x y;;
