import java.util.Scanner;

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

        while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        }

        System.out.print(sb.toString());
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        }

        System.out.print(sb.toString());
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        }

        System.out.print(sb.toString());
    } main {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        }

        System.out.print(sb.toString());
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        } in.hasNext() in.hasNext in {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        } int n = in.nextInt(); n in.nextInt() in.nextInt in int x = in.nextInt(); x in.nextInt() in.nextInt in if (n == 0) {
                break;
            } n == 0 n 0 {
                break;
            } break; int ret = 0; ret 0 int n3min = x / 3; n3min x / 3 x 3 for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            } int n3 = n; int n3 = n; n3 n n3 >= n3min n3 n3min n3-- n3-- n3 {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            } {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            } int x2 = x - n3; x2 x - n3 x n3 int n2 = n3 - 1; n2 n3 - 1 n3 1 int max = (x2 - 1) / 2; max (x2 - 1) / 2 (x2 - 1) x2 1 2 int hosei = x2 - 1 - n2; hosei x2 - 1 - n2 x2 - 1 - n2 x2 1 n2 max -= (hosei > 0) ? hosei : 0 max (hosei > 0) ? hosei : 0 (hosei > 0) hosei 0 hosei 0 ret += (max < 0) ? 0 : max ret (max < 0) ? 0 : max (max < 0) max 0 0 max sb.append(ret).append("\n") sb.append(ret).append sb.append(ret) sb.append sb ret "\n" System.out.print(sb.toString()) System.out.print System.out System System.out sb.toString() sb.toString sb String[] args args
import java.util.Scanner;

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

        while (in.hasNext()) {
            int n = in.nextInt();
            int x = in.nextInt();

            if (n == 0) {
                break;
            }

            int ret = 0;
            int n3min = x / 3;
            for (int n3 = n; n3 >= n3min; n3--) {
                int x2 = x - n3;
                int n2 = n3 - 1;

                int max = (x2 - 1) / 2;
                int hosei = x2 - 1 - n2;
                max -= (hosei > 0) ? hosei : 0;

                ret += (max < 0) ? 0 : max;
            }

            sb.append(ret).append("\n");
        }

        System.out.print(sb.toString());
    }
}