import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = ""; line "" int strN = 1; strN 1 for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		} int i = 0; int i = 0; i 0 i < strN i strN i++ i++ i {
			line += br.readLine() + " ";
		} {
			line += br.readLine() + " ";
		} line += br.readLine() + " " line br.readLine() + " " br.readLine() br.readLine br " " String[] param = line.split(" "); param line.split(" ") line.split line " " AtoZString(param) AtoZString param String[] args args static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	} AtoZString { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	} int K = Integer.parseInt(param[0]); K Integer.parseInt(param[0]) Integer.parseInt Integer param[0] param 0 int S = Integer.parseInt(param[1]); S Integer.parseInt(param[1]) Integer.parseInt Integer param[1] param 1 int count = 0; count 0 for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		} int i = 0; int i = 0; i 0 i <= K i K i++ i++ i {
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		} {
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		} for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			} int j = 0; int j = 0; j 0 j <= K j K j++ j++ j {
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			} {
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			} int k = S - (i + j); k S - (i + j) S (i + j) i j if(k >= 0 && k <= K) count++; k >= 0 && k <= K k >= 0 k 0 k <= K k K count++ count System.out.println(count) System.out.println System.out System System.out count String[] param param public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 1; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //2行、Iで1追加し、Dで1減らす、処理後の最大値を出力[1]
		int K = Integer.parseInt(param[0]);
		int S = Integer.parseInt(param[1]);
		
		int count = 0;
		
		for(int i = 0; i <= K; i++){
			for(int j = 0; j <= K; j++){
				int k = S - (i + j);
				if(k >= 0 && k <= K) count++;
			}
		}
		System.out.println(count);
	}
}