(* O(3^k) *)
let a, b, c, k = Scanf.scanf " %d %d %d %d" @@ fun a b c d -> a, b, c, d
let rec f i a b c =
  if i > k then a + b + c
  else List.fold_left max 0 [f (i + 1) (a * 2) b c; f (i + 1) a (b * 2) c; f (i + 1) a b (c * 2)]
let _ = Printf.printf "%d\n" @@ f 1 a b c