import java.util.Scanner;

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

		int k = sc.nextInt();
		int s = sc.nextInt();
		int sum = 0;

		for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		}
		System.out.println(sum);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int sum = 0;

		for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int sum = 0;

		for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		}
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();
		int sum = 0;

		for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		}
		System.out.println(sum);
	} 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 sum = 0; sum 0 for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		} int h = 0; int h = 0; h 0 h <= k h k h++ h++ h {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		} {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		} for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			} int i = 0; int i = 0; i 0 i <= k i k i++ i++ i {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			} {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			} if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				} h + i + k >= s && h + i <= s h + i + k >= s h + i + k h + i + k h i k s h + i <= s h + i h i s {
					sum = sum + 1;
				} sum = sum + 1 sum sum + 1 sum 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;

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

		int k = sc.nextInt();
		int s = sc.nextInt();
		int sum = 0;

		for (int h = 0; h <= k; h++) {
			for (int i = 0; i <= k; i++) {
				if (h + i + k >= s && h + i <= s) {
					sum = sum + 1;
				}
			}
		}
		System.out.println(sum);
	}
}