import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        } true {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        } int[] a = new int[]{sc.nextInt(), sc.nextInt()}; a new int[]{sc.nextInt(), sc.nextInt()} if (a[0] == 0 && a[1] == 0) {
                break;
            } a[0] == 0 && a[1] == 0 a[0] == 0 a[0] a 0 0 a[1] == 0 a[1] a 1 0 {
                break;
            } break; long count = 0; count 0 for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            } int i = 1; int i = 1; i 1 i < a[0] i a[0] a 0 i++ i++ i {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            } {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            } for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                } int j = i + 1; int j = i + 1; j i + 1 i 1 j < a[0] j a[0] a 0 j++ j++ j {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                } {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                } for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    } int k = j + 1; int k = j + 1; k j + 1 j 1 k <= a[0] k a[0] a 0 k++ k++ k {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    } {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    } if (i + j + k == a[1]) {
                            count++;
                        } i + j + k == a[1] i + j + k i + j + k i j k a[1] a 1 {
                            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) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            long count = 0;
            for (int i = 1; i < a[0]; i++) {
                for (int j = i + 1; j < a[0]; j++) {
                    for (int k = j + 1; k <= a[0]; k++) {
                        if (i + j + k == a[1]) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}