import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int result = 0;
		for (int i=0; i<=max; i++) {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		}
		System.out.println(Integer.toString(result));
	}

} import java.util.*; util.* java class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int result = 0;
		for (int i=0; i<=max; i++) {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		}
		System.out.println(Integer.toString(result));
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int result = 0;
		for (int i=0; i<=max; i++) {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		}
		System.out.println(Integer.toString(result));
	} main {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int result = 0;
		for (int i=0; i<=max; i++) {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		}
		System.out.println(Integer.toString(result));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int max = sc.nextInt(); max sc.nextInt() sc.nextInt sc int sum = sc.nextInt(); sum sc.nextInt() sc.nextInt sc int result = 0; result 0 for (int i=0; i<=max; i++) {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		} int i=0; int i=0; i 0 i<=max i max i++ i++ i {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		} {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		} for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			} int j=0; int j=0; j 0 j<=max j max j++ j++ j {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			} {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			} int tmp = sum - i - j; tmp sum - i - j sum - i - j sum i j if(0 <= tmp && tmp <= max) result++; 0 <= tmp && tmp <= max 0 <= tmp 0 tmp tmp <= max tmp max result++ result System.out.println(Integer.toString(result)) System.out.println System.out System System.out Integer.toString(result) Integer.toString Integer result String[] args args
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int result = 0;
		for (int i=0; i<=max; i++) {
			for (int j=0; j<=max; j++) {
				int tmp = sum - i - j;
				if(0 <= tmp && tmp <= max) result++;
			}
			
		}
		System.out.println(Integer.toString(result));
	}

}