import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		System.out.println(count);
	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		System.out.println(count);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		System.out.println(count);
	} main {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		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+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		} int i=0; int i=0; i 0 i<K+1 i K+1 K 1 i++ i++ i {
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		} {
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		} for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			} int j=0; int j=0; j 0 j<K+1 j K+1 K 1 j++ j++ j {
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			} {
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			} int k=S-i-j; k S-i-j S-i-j S i j int sum=i+j+k; sum i+j+k i+j+k i j k if(0<=k && k<=K)count++; 0<=k && k<=K 0<=k 0 k k<=K k K count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		System.out.println(count);
	}

} public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		System.out.println(count);
	}

} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int K=sc.nextInt();
		int S=sc.nextInt();
		int count=0;
		for(int i=0;i<K+1;i++){
			for(int j=0;j<K+1;j++){
				int k=S-i-j;
				int sum=i+j+k;
				if(0<=k && k<=K)count++;
				
			}
		}
		System.out.println(count);
	}

}
