import java.util.*;

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

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        } true {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if (n == 0 && x == 0)
                break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; int r = 0; r 0 for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++; int a = 1; int a = 1; a 1 a <= n a n a++ a++ a for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++; for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++; int b = 1; int b = 1; b 1 b <= n b n b++ b++ b for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++; for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++; int c = 1; int c = 1; c 1 c <=n c n c++ c++ c if (a < b && b < c && a + b + c == x)
                            r++; if (a < b && b < c && a + b + c == x)
                            r++; a < b && b < c && a + b + c == x a < b && b < c && a + b + c == x a < b a b b < c b c a + b + c == x a + b + c a + b + c a b c x r++ r System.out.println(r) System.out.println System.out System System.out r String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    }
} Main
import java.util.*;

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

        while (true) {
            int n = sc.nextInt();
            int x = sc.nextInt();

            if (n == 0 && x == 0)
                break;

            int r = 0;
            for (int a = 1; a <= n; a++)
                for (int b = 1; b <= n; b++)
                    for (int c = 1; c <=n; c++)
                        if (a < b && b < c && a + b + c == x)
                            r++;
            System.out.println(r);
        }
    }
}

