function main(input) {
	var r = input.split(/\s/)[0] / 1;
  	var g = input.split(/\s/)[1] / 1;
  	var b = input.split(/\s/)[2] / 1;
  	var n = input.split(/\s/)[3] / 1;
  	console.log((n * (n - 1)) / 2);
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));