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
 */
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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }
}
 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }
} 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);
        B solver = new B();
        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);
        B solver = new B();
        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) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    } B public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        } solve {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        } int K = in.nextInt(); K in.nextInt() in.nextInt in int S = in.nextInt(); S in.nextInt() in.nextInt in long count = 0; count 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) {
                        count++;
                    }
                }
            } 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) {
                        count++;
                    }
                }
            } {
                for (int Y = 0; Y <= K; Y++) {
                    int Z = S - (X + Y);
                    if (0 <= Z && Z <= K) {
                        count++;
                    }
                }
            } for (int Y = 0; Y <= K; Y++) {
                    int Z = S - (X + Y);
                    if (0 <= Z && Z <= K) {
                        count++;
                    }
                } 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) {
                        count++;
                    }
                } {
                    int Z = S - (X + Y);
                    if (0 <= Z && Z <= K) {
                        count++;
                    }
                } int Z = S - (X + Y); Z S - (X + Y) S (X + Y) X Y if (0 <= Z && Z <= K) {
                        count++;
                    } 0 <= Z && Z <= K 0 <= Z 0 Z Z <= K Z K {
                        count++;
                    } count++ count out.println(count) out.println out count 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }
} 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }
} 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
 */
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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int K = in.nextInt();
            int S = in.nextInt();

            long count = 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) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }
}

