import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    }
} Main public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    } main {
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int limit=scan.nextInt(); limit scan.nextInt() scan.nextInt scan int sum=scan.nextInt(); sum scan.nextInt() scan.nextInt scan int i i j; j int count=0; count 0 for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            } i=0; i=0 i 0 i<=limit i limit i++ i++ i {
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            } {
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            } for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                } j=0; j=0 j 0 j<=limit j limit j++ j++ j {
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                } {
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                } if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    } sum-i-j<=limit&&sum-i-j>=0 sum-i-j<=limit sum-i-j sum-i-j sum i j limit sum-i-j>=0 sum-i-j sum-i-j sum i j 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[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    }
} public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
            int limit=scan.nextInt();
            int sum=scan.nextInt();
            int i,j;
            int count=0;
            for(i=0;i<=limit;i++){
                for(j=0;j<=limit;j++){
                    if(sum-i-j<=limit&&sum-i-j>=0){
                        count++;
                    }
                }
            }
            System.out.println(count);
    }
}