fun main(arr: Array<String>) {
    println(readLine()!!.split(" ").map { it.toLong() }.let { solve(it[0], it[1], it[2], it[3]) })
}

fun solve(taka:Long, naka:Long, hiku:Long, k:Long):Long {
    if(k % 2 == 0L) {
        return taka - naka
    } else {
        return naka - taka
    }
}