let find_max m n = if m - n >= 0 then m else n in
    let rec pow m n =  if n - 1 >= 0 then m * pow m (n - 1) else 1 in 
    let a = ref 0 and b = ref 0 and c = ref 0 and k = ref 0 in
    Scanf.sscanf (read_line ()) "%d %d %d" (fun x y z -> a := x; b := y; c := z);
    Scanf.sscanf (read_line ()) "%d" (fun x -> k := x);
    print_int (!a + !b + !c + find_max (find_max !a !b) !c * pow 2 !k - find_max (find_max !a !b) !c); print_string "\n"