import java.util.*;

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

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    } main {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        } true {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        } int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan if (n == 0 && x == 0) break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; int count = 0; count 0 for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            } int i = 1; int i = 1; i 1 i < n i n ++i ++i i {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            } {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            } for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                } int j = i; int j = i; j i j < n j n ++j ++j j {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                } {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                } if (i == j) continue; i == j i j continue; int num = x - (i + j); num x - (i + j) x (i + j) i j if (num < 1) break; num < 1 num 1 break; if (num < j) break; num < j num j break; if (i != num && j != num && num <= n) count++; i != num && j != num && num <= n i != num && j != num && num <= n i != num i num j != num j num num <= n num n count++ count num = 0 num 0 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 scan = new Scanner(System.in);

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    }
} Main
import java.util.*;

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

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    }
}