import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    } 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 cnt = 0; cnt 0 for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        } int a=0; int a=0; a 0 a<=k a k a++ a++ a {
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        } {
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        } for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            } int b=0; int b=0; b 0 b<=k b k b++ b++ b {
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            } {
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            } int c = s - a - b; c s - a - b s - a - b s a b if( 0<=c && c<=k){
                    cnt++;
                } 0<=c && c<=k 0<=c 0 c c<=k c k {
                    cnt++;
                } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

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

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    }
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int cnt = 0;

        for(int a=0; a<=k; a++){
            for(int b=0; b<=k; b++){
                int c = s - a - b;
                if( 0<=c && c<=k){
                    cnt++;
                }        
            }
        }
        System.out.println(cnt);
    }
}