import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

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

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	} run {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					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 a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		} int a = 0; int a = 0; a 0 a <= k a k a++ a++ a {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		} {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		} for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			} int b = 0; int b = 0; b 0 b <= k b k b++ b++ b {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			} {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			} int c = s - a - b; c s - a - b s - a - b s a b if (0 <= c && c <= k) {
					count++;
				} 0 <= c && c <= k 0 <= c 0 c c <= k c k {
					count++;
				} count++ count System.out.println(count) System.out.println System.out System System.out count public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int count = 0;
		for (int a = 0; a <= k; a++) {
			for (int b = 0; b <= k; b++) {
				int c = s - a - b;
				if (0 <= c && c <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
