import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val A = sc.nextLong
    val B = sc.nextLong
    val C = sc.nextLong
    val K = sc.nextLong

    if (K % 2 == 0) {
      (A - B).toString
    } else {
      (B - A).toString
    }
  }
}
