import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    }
} import java.util.*; util.* java public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    }
} Main public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    } main {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    } int count = 0; count 0 boolean sw = false; sw false int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE double dMax = Double.MIN_VALUE; dMax Double.MIN_VALUE Double Double.MIN_VALUE double dMin = Double.MAX_VALUE; dMin Double.MAX_VALUE Double Double.MAX_VALUE 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 for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        } int i=0; int i=0; i 0 i<=k i k ++i ++i i {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        } {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        } for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            } int j = 0; int j = 0; j 0 j<=k j k ++j ++j j {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            } {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            } int a=s-i-j; a s-i-j s-i-j s i j if (a<=k && a>=0)
                {
                    ++count;
                } a<=k && a>=0 a<=k a k a>=0 a 0 {
                    ++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)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    }
} public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    }
} Main
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();

        for (int i=0;i<=k;++i)
        {
            for (int j = 0;j<=k;++j)
            {
                int a=s-i-j;
                if (a<=k && a>=0)
                {
                    ++count;
                }
            }
        }
        System.out.println(count);
    }
}