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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	} main {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	} BufferedReader input =new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) String str = input.readLine( ); str input.readLine( ) input.readLine input String[] strlist = str.split(" "); strlist str.split(" ") str.split str " " int k = Integer.parseInt(strlist[0]); k Integer.parseInt(strlist[0]) Integer.parseInt Integer strlist[0] strlist 0 int s = Integer.parseInt(strlist[1]); s Integer.parseInt(strlist[1]) Integer.parseInt Integer strlist[1] strlist 1 int count = 0; count 0 for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		} int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		} {
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		} for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			} int y = 0; int y = 0; y 0 y <= k y k y++ y++ y {
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			} {
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			} int z = s - x -y; z s - x -y s - x -y s x y if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				} z >= 0 && z <= k z >= 0 z 0 z <= k z k {
					count = count + 1;
					continue;
				} count = count + 1 count count + 1 count 1 continue; System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int k = Integer.parseInt(strlist[0]);
		int s = Integer.parseInt(strlist[1]);
		int count = 0;

		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x -y;
				if(z >= 0 && z <= k){
					count = count + 1;
					continue;
				}
			}
		}

		System.out.println(count);


	}

}
