import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        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 = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    }

} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    } main {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner int s = scanner.nextInt(); s scanner.nextInt() scanner.nextInt scanner int ans = 0; ans 0 for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        } int x = 0; int x = 0; x 0 x <= k x k x++ x++ x {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        } {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        } for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            } int y = 0; int y = 0; y 0 y <= x y x y++ y++ y {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            } {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            } for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                } int z = 0; int z = 0; z 0 z <= y z y z++ z++ z {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                } {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                } if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    } x + y + z == s x + y + z x + y + z x y z s {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    } if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6; x == y && y == z x == y x y y == z y z ans++ ans if (x == y || y == z || x == z) ans += 3;
                        else ans += 6; x == y || y == z || x == z x == y || y == z || x == z x == y x y y == z y z x == z x z ans += 3 ans 3 ans += 6 ans 6 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 = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        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 = scanner.nextInt();
        int s = scanner.nextInt();
        int ans = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= x; y++) {
                for (int z = 0; z <= y; z++) {
                    if (x + y + z == s) {
                        if (x == y && y == z) ans++;
                        else if (x == y || y == z || x == z) ans += 3;
                        else ans += 6;
                    }
                }
            }
        }
        System.out.println(ans);
    }

}
