import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        Integer K = Integer.parseInt(st.nextToken());
        Integer S = Integer.parseInt(st.nextToken());
        long ans=0;
        for (int i=0; i<=K; i++) {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        }
        System.out.println(ans);
        
    }

} import java.util.*; util.* java import java.io.*; io.* java class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        Integer K = Integer.parseInt(st.nextToken());
        Integer S = Integer.parseInt(st.nextToken());
        long ans=0;
        for (int i=0; i<=K; i++) {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        }
        System.out.println(ans);
        
    }

} Main public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        Integer K = Integer.parseInt(st.nextToken());
        Integer S = Integer.parseInt(st.nextToken());
        long ans=0;
        for (int i=0; i<=K; i++) {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        }
        System.out.println(ans);
        
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        Integer K = Integer.parseInt(st.nextToken());
        Integer S = Integer.parseInt(st.nextToken());
        long ans=0;
        for (int i=0; i<=K; i++) {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        }
        System.out.println(ans);
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) Integer K = Integer.parseInt(st.nextToken()); K Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st Integer S = Integer.parseInt(st.nextToken()); S Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st long ans=0; ans 0 for (int i=0; i<=K; i++) {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        } {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        } for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            } {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            } if(i+j>S)
                    continue; i+j>S i+j i j S continue; if(S-i-j<=K)
                    ans++; S-i-j<=K S-i-j S-i-j S i j K ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        Integer K = Integer.parseInt(st.nextToken());
        Integer S = Integer.parseInt(st.nextToken());
        long ans=0;
        for (int i=0; i<=K; i++) {

            for (int j=0; j<=K; j++) {
                if(i+j>S)
                    continue;
                if(S-i-j<=K)
                    ans++;
            }
        }
        System.out.println(ans);
        
    }

}
