import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	} main {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	} 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 num = 0; num 0 for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		} int x=0; int x=0; x 0 x<=Math.min(k, s) x Math.min(k, s) Math.min Math k s x++ x++ x {
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		} {
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		} for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			} int y=0; int y=0; y 0 y<=k y k y++ y++ y {
				if(0<=s-x-y && s-x-y<=k)num++;
			} {
				if(0<=s-x-y && s-x-y<=k)num++;
			} if(0<=s-x-y && s-x-y<=k)num++; 0<=s-x-y && s-x-y<=k 0<=s-x-y 0 s-x-y s-x-y s x y s-x-y<=k s-x-y s-x-y s x y k num++ num System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	}
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		int num = 0;
		for(int x=0; x<=Math.min(k, s); x++){
			for(int y=0; y<=k; y++){
				if(0<=s-x-y && s-x-y<=k)num++;
			}
		}
		System.out.println(num);
	}
}