import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } true {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        } String[] lines = br.readLine().split(" "); lines br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(lines[0]); n Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 int x = Integer.parseInt(lines[1]); x Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 if (n == 0 && x == 0) {
                break;
            } n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
                break;
            } break; int count = 0; count 0 int m = 0; m 0 for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            } int i = Math.max(1, x - n - (n - 1)); int i = Math.max(1, x - n - (n - 1)); i Math.max(1, x - n - (n - 1)) Math.max Math 1 x - n - (n - 1) x - n - (n - 1) x n (n - 1) n 1 i <= Math.min(n - 2, x / 3) i Math.min(n - 2, x / 3) Math.min Math n - 2 n 2 x / 3 x 3 i++ i++ i {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            } {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            } for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                } int j = Math.max(i + 1, x - n - i); int j = Math.max(i + 1, x - n - i); j Math.max(i + 1, x - n - i) Math.max Math i + 1 i 1 x - n - i x - n - i x n i j <= Math.min(n - 1, (x - i) / 2) j Math.min(n - 1, (x - i) / 2) Math.min Math n - 1 n 1 (x - i) / 2 (x - i) x i 2 j++ j++ j {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                } {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                } int k = x - i - j; k x - i - j x - i - j x i j if (k <= n && k > j) {
                        count++;
                    } k <= n && k > j k <= n k n k > j k j {
                        count++;
                    } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] lines = br.readLine().split(" ");
            int n = Integer.parseInt(lines[0]);
            int x = Integer.parseInt(lines[1]);
            if (n == 0 && x == 0) {
                break;
            }
            int count = 0;
            int m = 0;
            for (int i = Math.max(1, x - n - (n - 1)); i <= Math.min(n - 2, x / 3); i++) {
                for (int j = Math.max(i + 1, x - n - i); j <= Math.min(n - 1, (x - i) / 2); j++) {
                    int k = x - i - j;
                    if (k <= n && k > j) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }
}