import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int K = Integer.parseInt(scanner.next()); K Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int S = Integer.parseInt(scanner.next()); S Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner scanner.close() scanner.close scanner int ans = 0; ans 0 for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    ans++;
                }
            }
        } 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 (z >= 0 && z <= K) {
                    ans++;
                }
            }
        } {
            for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    ans++;
                }
            }
        } for (int y = 0; y <= K; y++) {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    ans++;
                }
            } int y = 0; int y = 0; y 0 y <= K y K y++ y++ y {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    ans++;
                }
            } {
                int z = S - x - y;
                if (z >= 0 && z <= K) {
                    ans++;
                }
            } int z = S - x - y; z S - x - y S - x - y S x y if (z >= 0 && z <= K) {
                    ans++;
                } z >= 0 && z <= K z >= 0 z 0 z <= K z K {
                    ans++;
                } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int K = Integer.parseInt(scanner.next());
        int S = Integer.parseInt(scanner.next());
        scanner.close();

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

        System.out.println(ans);
    }
}
