import java.util.Scanner;

public class Main {
    public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    }

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

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    }

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

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    }
} Main public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    } countWays {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    } int count = 0; count 0 for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        } {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        } for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            } int j = 1; int j = 1; j 1 j < i j i j++ j++ j {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            } {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            } for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                } int k = 1; int k = 1; k 1 k < j k j k++ k++ k {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                } {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                } if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    } i + j + k == x i + j + k i + j + k i j k x {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    } count++ count return count; count int n n int x x public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Main app = new Main();

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    } main {
        Scanner scan = new Scanner(System.in);
        Main app = new Main();

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) Main app = new Main(); app new Main() while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        } true {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        } int inN inN inX; inX int count; count inN = Integer.parseInt(scan.next()) inN Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan inX = Integer.parseInt(scan.next()) inX Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan if (inN == 0 && inX == 0) break; inN == 0 && inX == 0 inN == 0 inN 0 inX == 0 inX 0 break; count = app.countWays(inN, inX) count app.countWays(inN, inX) app.countWays app inN inX System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    }

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

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    }
} public class Main {
    public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    }

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

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public int countWays(int n, int x) {
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j < i; j++) {
                for (int k = 1; k < j; k++) {
                    if (i + j + k == x) {
//                        System.out.println(i + "+" + j + "+" + k);
                        count++;
                    }
                }
            }
        }
        return count;
    }

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

        while (true) {
            int inN, inX;
            int count;

            inN = Integer.parseInt(scan.next());
            inX = Integer.parseInt(scan.next());
            if (inN == 0 && inX == 0) break;

            count = app.countWays(inN, inX);
            System.out.println(count);
        }
    }
}

