import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int jouken = 0; jouken 0 while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        } jouken == 0 jouken 0 {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        } int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int kazu = 0; kazu 0 if (n == 0 && x == 0) {
                break;
            } n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
                break;
            } break; for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            } int i = 1; int i = 1; i 1 n >= i n i i++ i++ i {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            } {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            } for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                } int j = 1; int j = 1; j 1 n >= j n j j++ j++ j {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                } {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                } for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    } int k = 1; int k = 1; k 1 n >= k n k k++ k++ k {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    } {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    } int goukei = i + j + k; goukei i + j + k i + j + k i j k if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        } i != k && k != j && j != i && goukei == x&&i>j&&j>k i>j goukei == x j != i i != k && k != j && j != i && goukei == x&&i>j&&j>k i != k i k k != j k j j != i j i goukei == x goukei x i>j i j j>k j k {
                            kazu++;
                        } kazu++ kazu System.out.println(kazu) System.out.println System.out System System.out kazu String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int jouken = 0;

        while (jouken == 0) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int kazu = 0;
            if (n == 0 && x == 0) {
                break;
            }
            for (int i = 1; n >= i; i++) {
                for (int j = 1; n >= j; j++) {
                    for (int k = 1; n >= k; k++) {
                        int goukei = i + j + k;
                        if (i != k && k != j && j != i && goukei == x&&i>j&&j>k) {
                            kazu++;
                        }
                    }
                }
            }
            System.out.println(kazu);
        }
    }
}