import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	} main {
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	} 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 ct = 0; ct 0 for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		} 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(tmp <= max && tmp >= 0)
					ct ++;
			}
		} {
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		} for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			} int j = 0; int j = 0; j 0 j<= max j max j++ j++ j {
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			} {
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			} int tmp = sum - i - j; tmp sum - i - j sum - i - j sum i j if(tmp <= max && tmp >= 0)
					ct ++; tmp <= max && tmp >= 0 tmp <= max tmp max tmp >= 0 tmp 0 ct ++ ct System.out.println(ct) System.out.println System.out System System.out ct String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	}
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int max = sc.nextInt();
		int sum = sc.nextInt();
		int ct = 0;
		for(int i = 0; i <= max; i++){
			for(int j = 0; j<= max; j++){
				int tmp = sum - i - j;
				if(tmp <= max && tmp >= 0)
					ct ++;
			}
		}
		System.out.println(ct);
	}
}