defmodule Main do
  def main do
    [a, b, c] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    k = IO.gets("") |> String.trim |> String.to_integer
    a = String.to_integer(a)
    b = String.to_integer(b)
    c = String.to_integer(c)
    IO.puts(a + b + c - Enum.max([a, b, c]) + Enum.max([a, b, c]) * 2 * k)
  end
end