let rec f a b c k = 
if k = 0 then a+b+c
else if max (max a b) c = a then f (a*2) b c (k-1)
else if max (max a b) c = b then f a (b*2) c (k-1)
else f a b (c*2) (k-1)
let () =
let a, b, c = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c) in
let k = Scanf.scanf "%d\n" (fun x -> x) in
Printf.printf "%d\n" (f a b c k)