import java.util.Scanner;
 
class Main {
	int k;
	int s;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		k = sc.nextInt();
		s = sc.nextInt();
	}
	void solve(){
		int ans = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util class Main {
	int k;
	int s;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		k = sc.nextInt();
		s = sc.nextInt();
	}
	void solve(){
		int ans = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		}
		System.out.println(ans);
	}
} Main int k; k int s; s public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Main m = new Main(sc); m new Main(sc) m.solve() m.solve m sc.close() sc.close sc String[] args args Main(Scanner sc){
		k = sc.nextInt();
		s = sc.nextInt();
	} Main {
		k = sc.nextInt();
		s = sc.nextInt();
	} k = sc.nextInt() k sc.nextInt() sc.nextInt sc s = sc.nextInt() s sc.nextInt() sc.nextInt sc Scanner sc sc void solve(){
		int ans = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		}
		System.out.println(ans);
	} solve {
		int ans = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		}
		System.out.println(ans);
	} int ans = 0; ans 0 for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		} int x=0; int x=0; x 0 x<=k x k x++ x++ x {
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		} {
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		} for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			} int y=0; int y=0; y 0 y<=k y k y++ y++ y {
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			} {
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			} if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++; (s-(x+y)<=k)&&(s-(x+y)>=0) (s-(x+y)<=k) s-(x+y) s (x+y) x y k (s-(x+y)>=0) s-(x+y) s (x+y) x y 0 ans++ ans System.out.println(ans) System.out.println System.out System System.out ans
import java.util.Scanner;
 
class Main {
	int k;
	int s;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		k = sc.nextInt();
		s = sc.nextInt();
	}
	void solve(){
		int ans = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if((s-(x+y)<=k)&&(s-(x+y)>=0)) ans++;
			}
		}
		System.out.println(ans);
	}
}