import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int K=s.nextInt();
		int S=s.nextInt();
		int count=0;
		int i=0,j=0;
		
		for(i=0;i<=K;i++){
			for(j=0;j<=K;j++){
				if(S-i-j<=K&&S-i-j>=0)count++;
			}
		}
		
		System.out.print(count);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int K=s.nextInt();
		int S=s.nextInt();
		int count=0;
		int i=0,j=0;
		
		for(i=0;i<=K;i++){
			for(j=0;j<=K;j++){
				if(S-i-j<=K&&S-i-j>=0)count++;
			}
		}
		
		System.out.print(count);
	}

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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int K=s.nextInt();
		int S=s.nextInt();
		int count=0;
		int i=0,j=0;
		
		for(i=0;i<=K;i++){
			for(j=0;j<=K;j++){
				if(S-i-j<=K&&S-i-j>=0)count++;
			}
		}
		
		System.out.print(count);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int K=s.nextInt();
		int S=s.nextInt();
		int count=0;
		int i=0,j=0;
		
		for(i=0;i<=K;i++){
			for(j=0;j<=K;j++){
				if(S-i-j<=K&&S-i-j>=0)count++;
			}
		}
		
		System.out.print(count);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s=new Scanner(System.in);
		int K=s.nextInt();
		int S=s.nextInt();
		int count=0;
		int i=0,j=0;
		
		for(i=0;i<=K;i++){
			for(j=0;j<=K;j++){
				if(S-i-j<=K&&S-i-j>=0)count++;
			}
		}
		
		System.out.print(count);
	}

}