function main(input) {
  var _input = `1 2 3 1`
  var input = _input.split(' ');
  for (var i=0;i<input.length;i++){
    input[i] = parseInt(input[i]);
  }
  
  if(input[0] === input[1] && input[0] === input[2]) {
    console.log("0");
    return;
  }
  
  var manipulate = (input) => {
    var res_arr = [0,0,0];
    res_arr[0] = input[1] + input[2];
    res_arr[1] = input[0] + input[2];
    res_arr[2]= input[0] + input[1];
    
    return res_arr;
  }
  
  var res_arr = input;
  var l = input[3];
  for (var i=0;i<l;i++){
    res_arr = manipulate(res_arr);
  }
  
  var answer = res_arr[0] - res_arr[1];
  
  var checkLength = (num) => {
    return Math.abs(num).toString().length;
  }
    
  if(checkLength(answer) > 17) answer = "unfair";
  console.log(answer);
    
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));