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