import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    }


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

    Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    }


} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args void run() {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    } run {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int s = sc.nextInt(); s sc.nextInt() sc.nextInt sc long res = 0; res 0 for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        } int x=0; int x=0; x 0 x<=k x k x++ x++ x {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        } {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        } for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            } int y=0; int y=0; y 0 y<=k y k y++ y++ y {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            } {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            } int z = s - (x + y); z s - (x + y) s (x + y) x y if (0 <= z && z <= k) res++; 0 <= z && z <= k 0 <= z 0 z z <= k z k res++ res System.out.println(res) System.out.println System.out System System.out res public class Main {

    Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    }


} public class Main {

    Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    }


} Main
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int k = sc.nextInt();
        int s = sc.nextInt();

        long res = 0;

        for (int x=0; x<=k; x++) {
            for (int y=0; y<=k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) res++;
            }
        }

        System.out.println(res);

    }


}
