import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str[]=br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int k=Integer.parseInt(str[0]); k Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int s=Integer.parseInt(str[1]); s Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int result=0; result 0 for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        } int i=0; int i=0; i 0 i<=k i k i++ i++ i {
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        } {
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        } for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            } int j=0; int j=0; j 0 j<=k j k j++ j++ j {
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            } {
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            } if(s-i-j>=0&&s-i-j<=k)
                    result++; s-i-j>=0&&s-i-j<=k s-i-j>=0 s-i-j s-i-j s i j 0 s-i-j<=k s-i-j s-i-j s i j k result++ result System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int k=Integer.parseInt(str[0]);
        int s=Integer.parseInt(str[1]);
        
        int result=0;
        
        for(int i=0;i<=k;i++){
            for(int j=0;j<=k;j++){
                if(s-i-j>=0&&s-i-j<=k)
                    result++;
            }
        }
        
        System.out.println(result);
    }
}
