import java.util.Scanner;
public class Main{
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    }
} Main private static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    } main {
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    } 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 x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int 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<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        } {
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        } for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            } int y=0; int y=0; y 0 y<=Math.min(k,s-x) y Math.min(k,s-x) Math.min Math k s-x s x y++ y++ y {
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            } {
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            } int 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 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    }
} public class Main{
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;
public class Main{
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int k=sc.nextInt();
        int s=sc.nextInt();
        int ans=0;
        for(int x=0;x<=k;x++){
            for(int y=0;y<=Math.min(k,s-x);y++){
                int z=s-x-y;
                if(z>=0&&z<=k) ans++;
            }
        }
        System.out.println(ans);
    }
}