function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");
	var max = parseInt(tmp[0], 10);
	var sum = parseInt(tmp[1], 10);
	var count = 0;
	if (sum-2*max>=0) {
		for (i=sum-2*max;i<=max;i++) {
			if (sum-max-i>=0) {
				count += 2*max-sum+i+1;
			} else {
				count += sum-i+1;
			}
		}
	} else if (sum >= max){
		for (i=0;i<=max;i++) {
			if (sum-max-i>=0) {
				count += 2*max-sum+i+1;
			} else {
				count += sum-i+1;
			}
		}
	} else {
		for (i=0;i<=sum;i++) {
				count += sum-i+1;
			}
	}
	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));