import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	} main {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc int count = 0; count 0 for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		} int x = Math.max(0, s - 2 * k); int x = Math.max(0, s - 2 * k); x Math.max(0, s - 2 * k) Math.max Math 0 s - 2 * k s 2 * k 2 k x <= k x k x++ x++ x {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		} {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		} for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			} int y = Math.max(0, s - k - x); int y = Math.max(0, s - k - x); y Math.max(0, s - k - x) Math.max Math 0 s - k - x s - k - x s k x y <= Math.min(k, s - x) y Math.min(k, s - x) Math.min Math k s - x s x y++ y++ y {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			} {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			} count++ count 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) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;

		for (int x = Math.max(0, s - 2 * k); x <= k; x++) {
			for (int y = Math.max(0, s - k - x); y <= Math.min(k, s - x); y++) {
				//int z = s - x - y;
				//System.out.println(x + "," + y + "," + z);
				count++;
			}
		}
		System.out.println(count);
	}
}