import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k  =sc.nextInt() k sc.nextInt() sc.nextInt sc s = sc.nextInt(); s sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		} int x=0; int x=0; x 0 x<=k x k x++ x++ x {
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		} {
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		} for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			} int y=0; int y=0; y 0 y<=k y k y++ y++ y {
				if(x+y<=s && x+y+k>=s)
					cnt++;
			} {
				if(x+y<=s && x+y+k>=s)
					cnt++;
			} if(x+y<=s && x+y+k>=s)
					cnt++; x+y<=s && x+y+k>=s x+y<=s x+y x y s x+y+k>=s x+y+k x+y+k x y k s cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k  =sc.nextInt(), s = sc.nextInt();
		
		int cnt = 0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(x+y<=s && x+y+k>=s)
					cnt++;
			}
		}
		
		System.out.println(cnt);
	}

}
