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