'use strict'

function Main(input) {
  let takahashi = [Number(input.split(' ')[0])];
  let chuhashi = [Number(input.split(' ')[1])];
  let syohashi = [Number(input.split(' ')[2])];
  const K = Number(input.split(' ')[3]);

  const answer = chuhashi - takahashi;
  
  if(K === 0) {
    console.log(answer * -1);
  } else {
    console.log(answer);
  }
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));