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();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	}

} 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();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	} main {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	} 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 if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		} 3 * k < s 3 * k 3 k s {
			System.out.println("");
			System.exit(0);
		} System.out.println("") System.out.println System.out System System.out "" System.exit(0) System.exit System 0 int r = 0; r 0 for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		} int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		} {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		} for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			} int y = 0; int y = 0; y 0 y <= k && y <= s - x y <= k y k y <= s - x y s - x s x y++ y++ y {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			} {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			} if (0 <= s - x - y && s - x - y <= k) {
					r++;
				} 0 <= s - x - y && s - x - y <= k 0 <= s - x - y 0 s - x - y s - x - y s x y s - x - y <= k s - x - y s - x - y s x y k {
					r++;
				} r++ r System.out.println(r) System.out.println System.out System System.out r 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();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	}

} 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();

		if (3 * k < s) {
			System.out.println("");
			System.exit(0);
		}

		int r = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k && y <= s - x; y++) {
				if (0 <= s - x - y && s - x - y <= k) {
					r++;
				}
			}
		}
		System.out.println(r);

	}

}
