import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    } main {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] line = sc.nextLine().split(" "); line sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int K = Integer.parseInt(line[0]); K Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int S = Integer.parseInt(line[1]); S Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int ans = 0; ans 0 for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        } int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        } {
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        } for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            } {
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            } int target = S -x - y; target S -x - y S -x - y S x y if(target >= 0 && target <= K){
                        ans++;
                    } target >= 0 && target <= K target >= 0 target 0 target <= K target K {
                        ans++;
                    } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");

        int K = Integer.parseInt(line[0]);
        int S = Integer.parseInt(line[1]);

        int ans = 0;
        for(int x = 0;x <= K;x++){
            for(int y = 0;y <= K;y++){
                    int target = S -x - y;
                    if(target >= 0 && target <= K){
                        ans++;
                    }
            }
        }    
        System.out.println(ans);
    }
}
