import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
} import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
} Main public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    } main {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    } try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        } {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        } BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in)) BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in)) new BufferedReader(
                new InputStreamReader(System.in)) final String s = reader.readLine(); s reader.readLine() reader.readLine reader final String[] sl = s.split(" "); sl s.split(" ") s.split s " " int K = Integer.parseInt(sl[0]); K Integer.parseInt(sl[0]) Integer.parseInt Integer sl[0] sl 0 int S = Integer.parseInt(sl[1]); S Integer.parseInt(sl[1]) Integer.parseInt Integer sl[1] sl 1 int cnt = 0; cnt 0 for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            } int x = 0; int x = 0; x 0 x <= K x K x++ x++ x {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            } {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            } for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                } {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                } if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    } x + y <= S x + y x y S {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    } int z = S - x - y; z S - x - y S - x - y S x y if (z <= K) cnt++; z <= K z K cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
} public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
} Main
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String[] sl = s.split(" ");
            int K = Integer.parseInt(sl[0]);
            int S = Integer.parseInt(sl[1]);

            int cnt = 0;

            for (int x = 0; x <= K; x++) {
                for (int y = 0; y <= K; y++) {
                    if (x + y <= S) {
                        int z = S - x - y;
                        if (z <= K) cnt++;
                    }
                }
            }

            System.out.println(cnt);
        }
    }
}
