import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int k=scan.nextInt(),s=scan.nextInt(),a=0,i,j;
		scan.close();
		for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		}
		System.out.print(a);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int k=scan.nextInt(),s=scan.nextInt(),a=0,i,j;
		scan.close();
		for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		}
		System.out.print(a);
	}
} Main public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int k=scan.nextInt(),s=scan.nextInt(),a=0,i,j;
		scan.close();
		for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		}
		System.out.print(a);
	} main {
		Scanner scan=new Scanner(System.in);
		int k=scan.nextInt(),s=scan.nextInt(),a=0,i,j;
		scan.close();
		for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		}
		System.out.print(a);
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int k=scan.nextInt() k scan.nextInt() scan.nextInt scan s=scan.nextInt() s scan.nextInt() scan.nextInt scan a=0 a 0 i i j; j scan.close() scan.close scan for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		} i=0; i=0 i 0 i<=k i k i++ i++ i {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		} {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		} for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			} j=0; j=0 j 0 j<=k j k j++ j++ j {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			} {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			} if(i+j>s) break; i+j>s i+j i j s break; if(k>=s-i-j) a++; k>=s-i-j k s-i-j s-i-j s i j a++ a System.out.print(a) System.out.print System.out System System.out a String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int k=scan.nextInt(),s=scan.nextInt(),a=0,i,j;
		scan.close();
		for(i=0;i<=k;i++) {
			for(j=0;j<=k;j++) {
				if(i+j>s) break;
				if(k>=s-i-j) a++;
			}
		}
		System.out.print(a);
	}
}