import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    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 num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        }
        
        System.out.println(cnt);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        }
        
        System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        }
        
        System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int sum = sc.nextInt(); sum sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        } int x = 0; int x = 0; x 0 x<=num x num x++ x++ x {
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        } {
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        } for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            } int y = 0; int y = 0; y 0 y<=num y num y++ y++ y {
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            } {
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            } if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                } (sum - (x+y) <= num) && (sum - (x+y) >= 0) (sum - (x+y) <= num) sum - (x+y) sum (x+y) x y num (sum - (x+y) >= 0) sum - (x+y) sum (x+y) x y 0 {
                    cnt++;
                } 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 num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        }
        
        System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    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 num = sc.nextInt();
        int sum = sc.nextInt();
        
        int cnt = 0;
        
        for(int x = 0; x<=num; x++){
            for(int y = 0; y<=num; y++){
                if((sum - (x+y) <= num) && (sum - (x+y) >= 0)){
                    cnt++;
                }
            }
        }
        
        System.out.println(cnt);
	}
}