import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) BSumOfThreeIntegers solver = new BSumOfThreeIntegers(); solver new BSumOfThreeIntegers() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        }

    } BSumOfThreeIntegers public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        } solve {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        } int k = in.nextInt() k in.nextInt() in.nextInt in s = in.nextInt(); s in.nextInt() in.nextInt in long ans = 0; ans 0 for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            } int x = Math.max(0, s - 2 * k); int x = Math.max(0, s - 2 * k); x Math.max(0, s - 2 * k) Math.max Math 0 s - 2 * k s 2 * k 2 k x <= Math.min(k, s) x Math.min(k, s) Math.min Math k s x++ x++ x {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            } {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            } ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0) ans Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0) Math.max Math Math.min(k, s - x) - Math.max(0, s - x - k) + 1 Math.min(k, s - x) - Math.max(0, s - x - k) Math.min(k, s - x) Math.min Math k s - x s x Math.max(0, s - x - k) Math.max Math 0 s - x - k s - x - k s x k 1 0 out.println(ans) out.println out ans int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BSumOfThreeIntegers solver = new BSumOfThreeIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSumOfThreeIntegers {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt(), s = in.nextInt();
            long ans = 0;
            for (int x = Math.max(0, s - 2 * k); x <= Math.min(k, s); x++) {
                ans += Math.max(Math.min(k, s - x) - Math.max(0, s - x - k) + 1, 0);
            }
            out.println(ans);
        }

    }
}

