import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                }
        }
} import java.util.*; util.* java class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                }
        }
} Main public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                }
        } main {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                }
        } try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                } {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        } true {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        } int n = sc.nextInt() n sc.nextInt() sc.nextInt sc 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;
                                } break; int ans = 0; ans 0 for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                } int i = 1; int i = 1; i 1 i <= n && i <= x i <= n i n i <= x i x i++ i++ i {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                } {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                } for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        } int j = i + 1; int j = i + 1; j i + 1 i 1 j < n && i + j <= x && x - i > 2 * j j < n && i + j <= x && x - i > 2 * j j < n j n i + j <= x i + j i j x x - i > 2 * j x - i x i 2 * j 2 j j++ j++ j {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        } {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        } if (x - i - j <= n) {
                                                        ans++;
                                                } x - i - j <= n x - i - j x - i - j x i j n {
                                                        ans++;
                                                } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                int n = sc.nextInt(), x = sc.nextInt();
                                if (n == 0 && x == 0) {
                                        break;
                                }
                                int ans = 0;
                                for (int i = 1; i <= n && i <= x; i++) {
                                        for (int j = i + 1; j < n && i + j <= x && x - i > 2 * j; j++) {
                                                if (x - i - j <= n) {
                                                        ans++;
                                                }
                                        }
                                }
                                System.out.println(ans);
                        }
                }
        }
}