import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

        System.out.println(res);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

        System.out.println(res);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

        System.out.println(res);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

        System.out.println(res);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int s = Integer.parseInt(sc.next()); s Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int res = 0; res 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) {
                    res++;
                }
            }
        } 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) {
                    res++;
                }
            }
        } {
            for (int y = 0; y <= k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) {
                    res++;
                }
            }
        } for (int y = 0; y <= k; y++) {
                int z = s - (x + y);
                if (0 <= z && z <= k) {
                    res++;
                }
            } 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) {
                    res++;
                }
            } {
                int z = s - (x + y);
                if (0 <= z && z <= k) {
                    res++;
                }
            } int z = s - (x + y); z s - (x + y) s (x + y) x y if (0 <= z && z <= k) {
                    res++;
                } 0 <= z && z <= k 0 <= z 0 z z <= k z k {
                    res++;
                } res++ res System.out.println(res) System.out.println System.out System System.out res String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

        System.out.println(res);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int s = Integer.parseInt(sc.next());

        int res = 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) {
                    res++;
                }
            }
        }

        System.out.println(res);
    }
}
