import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    } main {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    } 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 sum = 0; sum 0 for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        } int i=0; int i=0; i 0 i<=K i K i++ i++ i {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        } {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        } for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            } int j=0; int j=0; j 0 j<=K j K j++ j++ j {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            } {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            } int z = S - i - j; z S - i - j S - i - j S i j if(0 <= z && z <= K)
                {
                    sum++;
                } 0 <= z && z <= K 0 <= z 0 z z <= K z K {
                    sum++;
                } sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int sum = 0;
        for(int i=0;i<=K;i++)
        {
            for(int j=0;j<=K;j++)
            {
                int z = S - i - j;
                if(0 <= z && z <= K)
                {
                    sum++;
                }
            }
        }
        System.out.println(sum);
    }
}