function combination(input) {
	var max = input.split(" ")[0];
	var sum = input.split(" ")[1];
	var count = 0;
	if(sum <= max){
		for(var x = 0; x < sum+1; x++){
			for(var y = 0; y < sum+1-x; y++){
				for(var z = 0; z < sum+1-x-y; z++){
					if(z===sum-x-y){
						count++;
					}
				}
			}
		}
	} else if (sum > max){
		for(var x = 0; x < max+1; x++){
			if(sum-x <= max){
				for(var y = 0; y < sum+1-x; y++){
					for(var z = 0; z < sum+1-x-y; z++){
						if(z===sum-x-y){
							count++;
						}
					}
				}
			}else if(sum-x > max){
				for(var y = 0; y < max+1; y++){
					if(sum-x-y <= max){
						for(var z = 0; z < sum+1-x-y; z++){
							if(z===sum-x-y){
								count++;
							}
						}
					}else if(sum-x-y > max){

					}
				}
			}
		}
	}
	console.log(count);
}

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