

main = do
  [a,b,c,k] <- map read . words <$> getLine :: IO [Int]
  putStrLn $ solve a b c k

solve :: Int -> Int -> Int-> Int -> String
solve a b c k =
  ans'
  where
    sum = (a+b+c)*2^k
    x = if (k `mod` 2) == 0 then div (sum - 3) 9 else div (sum + 3) 9
    ak = if (k `mod` 2) == 0 then (a*(x+1)+(b+c)*x) else (a*x+(b+c)*(k+1))
    bk = if (k `mod` 2) == 0 then (b*(x+1)+(a+c)*x) else (b*x+(a+c)*(k+1))
    ans = ak - bk
    ans' = if (abs ans) > 10^18 then "Unfair" else show ans
