process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const [A,B,C,K] = lines[0].split(" ").map(v=>BigInt(v));
    console.log((K%2n===0?A-B:B-A).toString());
    
});
