import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    }
} import java.util.*; util.* java public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int S = sc.nextInt(); S sc.nextInt() sc.nextInt sc int K2 = K * 2; K2 K * 2 K 2 int count = 0; count 0 for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            } int X = 0; int X = 0; X 0 X <= K X K X++ X++ X {
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            } {
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            } if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                } K2 + X >= S K2 + X K2 X S {
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                } for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    } int Y = 0; int Y = 0; Y 0 Y <= K Y K Y++ Y++ Y {
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    } {
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    } int sxy = S - X -Y; sxy S - X -Y S - X -Y S X Y if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        } 0 <= sxy && sxy <= K 0 <= sxy 0 sxy sxy <= K sxy K {
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    }
} public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int K = sc.nextInt();
            int S = sc.nextInt();
            int K2 = K * 2;

            int count = 0;
            for(int X = 0;X <= K;X++){
                if(K2 + X >= S){
                    for(int Y = 0;Y <= K;Y++){
                        int sxy = S - X -Y;
                        
                        if(0 <= sxy && sxy <= K){
                            //System.out.println("X"+X+"Y"+Y+"sxy"+sxy);
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
    }
}