import java.util.*;
import java.math.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	/*static void sort(int[] A,int l,int r) {
		if(l=r) {
			
		}
		sort(A,0,(l+r)/2);
		sort(A,1+ (l+r)/2,r);
		
	}*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		System.out.println(count);
		
		
	}

} import java.util.*; util.* java import java.math.*; math.* java import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
	/*static void sort(int[] A,int l,int r) {
		if(l=r) {
			
		}
		sort(A,0,(l+r)/2);
		sort(A,1+ (l+r)/2,r);
		
	}*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		System.out.println(count);
		
		
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		System.out.println(count);
		
		
	} main {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		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 i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		} int i=0; int i=0; i 0 i<=K && S-i>=0 i<=K i K S-i>=0 S-i S i 0 i++ i++ i {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		} {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		} int sum=S-i; sum S-i S i if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			} sum<=K sum K {
				count+=sum+1;
				//System.out.println(sum+1);
			} count+=sum+1 count sum+1 sum 1 {
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			} int dif=Math.max(0, 2*K - sum +1); dif Math.max(0, 2*K - sum +1) Math.max Math 0 2*K - sum +1 2*K - sum 2*K 2 K sum 1 count+=dif count dif System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	/*static void sort(int[] A,int l,int r) {
		if(l=r) {
			
		}
		sort(A,0,(l+r)/2);
		sort(A,1+ (l+r)/2,r);
		
	}*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		System.out.println(count);
		
		
	}

} public class Main {
	/*static void sort(int[] A,int l,int r) {
		if(l=r) {
			
		}
		sort(A,0,(l+r)/2);
		sort(A,1+ (l+r)/2,r);
		
	}*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		System.out.println(count);
		
		
	}

} Main
import java.util.*;
import java.math.*;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	/*static void sort(int[] A,int l,int r) {
		if(l=r) {
			
		}
		sort(A,0,(l+r)/2);
		sort(A,1+ (l+r)/2,r);
		
	}*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		
		//X+Y+Z=S   0<=X,Y,Z<=K

		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		
		for(int i=0;i<=K && S-i>=0;i++) {//X=i固定
			int sum=S-i;
			//System.out.println("i"+i);
			if(sum<=K) {
				count+=sum+1;
				//System.out.println(sum+1);
			}else{
				int dif=Math.max(0, 2*K - sum +1);
				//System.out.println(dif);
				count+=dif;
			}
		}
		System.out.println(count);
		
		
	}

}