// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
        int ans=0;
        for (int a=0;a<=k;a++){
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        }
     
		System.out.println(ans);        
    
    }
}
 import java.util.*; util.* java import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
        int ans=0;
        for (int a=0;a<=k;a++){
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        }
     
		System.out.println(ans);        
    
    }
} Main public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
        int ans=0;
        for (int a=0;a<=k;a++){
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        }
     
		System.out.println(ans);        
    
    } main {
        Scanner sc = new Scanner(System.in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
        int ans=0;
        for (int a=0;a<=k;a++){
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        }
     
		System.out.println(ans);        
    
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = parseInt(sc.next()); k parseInt(sc.next()) parseInt sc.next() sc.next sc int s = parseInt(sc.next()); s parseInt(sc.next()) parseInt sc.next() sc.next sc sc.close() sc.close sc int ans=0; ans 0 for (int a=0;a<=k;a++){
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        } int a=0; int a=0; a 0 a<=k a k a++ a++ a {
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        } {
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        } for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            } int b=0; int b=0; b 0 b<=k b k b++ b++ b {
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            } {
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            } if (s-a-b<=k && s-a-b>=0){
                    ans++;
                } s-a-b<=k && s-a-b>=0 s-a-b<=k s-a-b s-a-b s a b k s-a-b>=0 s-a-b s-a-b s a b 0 {
                    ans++;
                } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
		int k = parseInt(sc.next());
		int s = parseInt(sc.next());
		sc.close();
        int ans=0;
        for (int a=0;a<=k;a++){
            for (int b=0;b<=k;b++){
                if (s-a-b<=k && s-a-b>=0){
                    ans++;
                }
            }
        }
     
		System.out.println(ans);        
    
    }
}

