import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    } main {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan scan.close() scan.close scan String[] ks = str.split(" "); ks str.split(" ") str.split str " " int n = 0; n 0 int k = Integer.parseInt(ks[0]); k Integer.parseInt(ks[0]) Integer.parseInt Integer ks[0] ks 0 int s = Integer.parseInt(ks[1]); s Integer.parseInt(ks[1]) Integer.parseInt Integer ks[1] ks 1 for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        } 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) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        } {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        } for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            } 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) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            } {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            } int z = s - x - y; z s - x - y s - x - y s x y if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                } 0 <= z && z <= k 0 <= z 0 z z <= k z k {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                } n++ n System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();

        String[] ks = str.split(" ");

        int n = 0;

        int k = Integer.parseInt(ks[0]);
        int s = Integer.parseInt(ks[1]);

        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (0 <= z && z <= k) {
                    //System.out.println(x + ", " + y + ", " + z);
                    n++;
                }
            }
        }

        System.out.println(n);

    }
}
