import java.io.*;

class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        }
    }
} import java.io.*; io.* java class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        }
    }
} Main public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int output = 0; output 0 try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        } catch(IOException e){
            System.out.println(e.getMessage());
        } IOException e {
            System.out.println(e.getMessage());
        } System.out.println(e.getMessage()) System.out.println System.out System System.out e.getMessage() e.getMessage e {
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } String[] keyboardInput = br.readLine().split(" "); keyboardInput br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int K = Integer.parseInt(keyboardInput[0]); K Integer.parseInt(keyboardInput[0]) Integer.parseInt Integer keyboardInput[0] keyboardInput 0 int S = Integer.parseInt(keyboardInput[1]); S Integer.parseInt(keyboardInput[1]) Integer.parseInt Integer keyboardInput[1] keyboardInput 1 for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            } 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 >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            } {
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            } for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                } {
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                } if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    } S - x - y >= 0 && S - x - y <= K S - x - y >= 0 S - x - y S - x - y S x y 0 S - x - y <= K S - x - y S - x - y S x y K {
                        output++;
                    } output++ output System.out.println(output) System.out.println System.out System System.out output String[] args args
import java.io.*;

class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int output = 0;
        try{
            String[] keyboardInput = br.readLine().split(" ");
            int K = Integer.parseInt(keyboardInput[0]);
            int S = Integer.parseInt(keyboardInput[1]);
            for(int x = 0; x <= K; x++){
                for(int y = 0; y <= K; y++){
                    if(S - x - y >= 0 && S - x - y <= K){
                        output++;
                    }
                }
            }
            System.out.println(output);
        } catch(IOException e){
            System.out.println(e.getMessage());
        }
    }
}