import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, x, count = 0;

		while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		}
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, x, count = 0;

		while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, x, count = 0;

		while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		int n, x, count = 0;

		while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int n n x x count = 0; count 0 while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		} true {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		} n = scanner.nextInt() n scanner.nextInt() scanner.nextInt scanner x = scanner.nextInt() x scanner.nextInt() scanner.nextInt scanner count = 0 count 0 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 i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; int i = 1; int i = 1; i 1 i <= n i n i++ i++ i for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; int i2 = i; int i2 = i; i2 i i2 <= n i2 n i2++ i2++ i2 for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; int i3 = i2; int i3 = i2; i3 i2 i3 <= n i3 n i3++ i3++ i3 if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++; !(i == i2 || i2 == i3 || i3 == i) (i == i2 || i2 == i3 || i3 == i) i == i2 || i2 == i3 || i3 == i i == i2 i i2 i2 == i3 i2 i3 i3 == i i3 i if (i + i2 + i3 == x)
								count++; i + i2 + i3 == x i + i2 + i3 i + i2 + i3 i i2 i3 x count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n, x, count = 0;

		while (true) {
			n = scanner.nextInt();
			x = scanner.nextInt();
			count = 0;

			if (n == 0 && x == 0)
				break;

			for (int i = 1; i <= n; i++)
				for (int i2 = i; i2 <= n; i2++)
					for (int i3 = i2; i3 <= n; i3++)
						if (!(i == i2 || i2 == i3 || i3 == i))
							if (i + i2 + i3 == x)
								count++;

			System.out.println(count);
		}
	}
}