import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner 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();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    } 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 sc.close() sc.close sc int ans = 0; ans 0 for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= 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 Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            } int Y = 0; int Y = 0; Y 0 Y <= K Y K Y++ Y++ Y {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            } {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            } int Z = 0; Z 0 Z = S - X - Y Z S - X - Y S - X - Y S X Y if(Z >= 0 && Z <= K) {
                    ans++;
                } Z >= 0 && Z <= K Z >= 0 Z 0 Z <= K Z 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) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int K = sc.nextInt();
        int S = sc.nextInt();

        sc.close();

        
        int ans = 0;
        
        for(int X = 0; X <= K; X++) {
            for (int Y = 0; Y <= K; Y++) {
                int Z = 0;
                Z = S - X - Y;
                if(Z >= 0 && Z <= K) {
                    ans++;
                }
                
            }
        } 
        System.out.println(ans);
    }
}