import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	}

} Main public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	} main {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int k = scan.nextInt() k scan.nextInt() scan.nextInt scan s = scan.nextInt(); s scan.nextInt() scan.nextInt scan int result=0; result 0 for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		} 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<=k && 0<=z)result++;
			}
		} {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		} for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			} int y=0; int y=0; y 0 y<=k y k y++ y++ y {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			} {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			} int z = s-(x+y); z s-(x+y) s (x+y) x y if(z<=k && 0<=z)result++; z<=k && 0<=z z<=k z k 0<=z 0 z result++ result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	}

} public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt(), s = scan.nextInt();
		int result=0;
		for(int x=0; x<=k; x++) {
			for(int y=0; y<=k; y++) {
				int z = s-(x+y);
				if(z<=k && 0<=z)result++;
			}
		}
		System.out.println(result);
	}

}