import Foundation

func solution(A: Int, B: Int, C: Int, K: Int) -> String {
   var K = K
   var A = A
   var B = B
   var C = C
   
   while K > 0 {
      let haveA = A
      let haveB = B
      let haveC = C
      
      A = haveB + haveC
      B = haveA + haveC
      C = haveA + haveB
      
      if abs(A - B) > Int(pow(10.0, 18.0)) { return "Unfair"}
      
      K -= 1
   }
   
   return String(A - B)
}

let ABCK = readLine()!.components(separatedBy: " ").map { Int($0)! }

print(solution(A: ABCK[0], B: ABCK[1], C: ABCK[2], K: ABCK[3]))