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 ans = 0;

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        System.out.println(ans);
    }
} 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 ans = 0;

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        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();
        int ans = 0;

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);

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

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        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 int ans = 0; ans 0 for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        } {
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        } int X = i; X i for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            } {
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            } int Y = j; Y j if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                } 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 {
                    ans += 1;
                } ans += 1 ans 1 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();
        int ans = 0;

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        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();
        int ans = 0;

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        System.out.println(ans);
    }
} 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 ans = 0;

        for(int i=0; i<=K; i++){
            int X = i;
            for(int j=0; j<=K; j++){
                int Y = j;
                if(S-X-Y>=0 && S-X-Y<=K){
                    ans += 1;
                }
            }
        }

        System.out.println(ans);
    }
}