main = do
    [a, b, c] <- map read . words <$> getLine
    k <- readLn
    putStrLn $ show $ ans a b c k

ans a b c k =
    let
        maxv = foldl1 max [a, b, c]
        rec acc 0 k = acc
        rec acc n k = rec (acc * k) (n - 1) k
        tmp = rec maxv k 2
    in
        a + b + c + tmp - maxv
