import java.util.Scanner;


public class Main {
	static int A,B;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	static int A,B;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	}
} Main static int A A B; B public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) A = sc.nextInt() A sc.nextInt() sc.nextInt sc B = sc.nextInt() B sc.nextInt() sc.nextInt sc sc.close() sc.close sc int ans = 0 ; ans 0 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 } int i = 0 ; int i = 0 ; i 0 i < A+1 i A+1 A 1 i++ i++ i {
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 } {
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 } for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 } int j = 0 ; int j = 0 ; j 0 j < A+1 j A+1 A 1 j++ j++ j {
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 } {
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 } if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 } B-i-j<=A && B-i-j>=0 B-i-j<=A B-i-j B-i-j B i j A B-i-j>=0 B-i-j B-i-j B i j 0 {
						 ans+=1;
				 } ans+=1 ans 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	static int A,B;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	}
} public class Main {
	static int A,B;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	}
} Main
import java.util.Scanner;


public class Main {
	static int A,B;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 A = sc.nextInt();
		 B = sc.nextInt();
		 sc.close();


		 int ans = 0 ;

		 for(int i = 0 ; i < A+1 ; i++){
			 for(int j = 0 ; j < A+1 ; j++){
					 if(B-i-j<=A && B-i-j>=0){
						 ans+=1;
				 }
			 }
		 }

		 System.out.println(ans);
	}
}
