import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    }

} import java.util.*; util.* java public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    }

} Main static int MOD = 1000000007; MOD 1000000007 public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    } main {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k=sc.nextInt() k sc.nextInt() sc.nextInt sc s=sc.nextInt(); s sc.nextInt() sc.nextInt sc int ans=0; ans 0 for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        } int i=0; int i=0; i 0 i<k+1 i k+1 k 1 i++ i++ i for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        } for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        } int j=0; int j=0; j 0 j<k+1 j k+1 k 1 j++ j++ j {
            if(i+j<=s&&i+j+k>=s)ans++;
        } {
            if(i+j<=s&&i+j+k>=s)ans++;
        } if(i+j<=s&&i+j+k>=s)ans++; i+j<=s&&i+j+k>=s i+j<=s i+j i j s i+j+k>=s i+j+k i+j+k i j k s ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    }

} public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    }

} Main
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int k=sc.nextInt(),s=sc.nextInt();
        int ans=0;
        for(int i=0;i<k+1;i++)for(int j=0;j<k+1;j++){
            if(i+j<=s&&i+j+k>=s)ans++;
        }
        System.out.println(ans);

    }

}
