import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int n = 0, x = 0;

		n = scane.nextInt();
		x = scane.nextInt();

		int count =0;


		while ((n+x) != 0) {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		}



	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int n = 0, x = 0;

		n = scane.nextInt();
		x = scane.nextInt();

		int count =0;


		while ((n+x) != 0) {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		}



	}
} Main public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int n = 0, x = 0;

		n = scane.nextInt();
		x = scane.nextInt();

		int count =0;


		while ((n+x) != 0) {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		}



	} main {

		Scanner scane = new Scanner(System.in);

		int n = 0, x = 0;

		n = scane.nextInt();
		x = scane.nextInt();

		int count =0;


		while ((n+x) != 0) {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		}



	} Scanner scane = new Scanner(System.in); scane new Scanner(System.in) int n = 0 n 0 x = 0; x 0 n = scane.nextInt() n scane.nextInt() scane.nextInt scane x = scane.nextInt() x scane.nextInt() scane.nextInt scane int count =0; count 0 while ((n+x) != 0) {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		} (n+x) != 0 (n+x) n x 0 {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		} count =0 count 0 for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			} int i= n; int i= n; i n i>0 i 0 --i --i i {
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			} {
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			} for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				} int j = i-1; int j = i-1; j i-1 i 1 j>0 j 0 --j --j j {
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				} {
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				} for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					} int t =j-1; int t =j-1; t j-1 j 1 t>0 t 0 --t --t t {

						if((i+j+t) == x){
							count++;
						}

					} {

						if((i+j+t) == x){
							count++;
						}

					} if((i+j+t) == x){
							count++;
						} (i+j+t) == x (i+j+t) i+j+t i j t x {
							count++;
						} count++ count System.out.println(count) System.out.println System.out System System.out count n = scane.nextInt() n scane.nextInt() scane.nextInt scane x = scane.nextInt() x scane.nextInt() scane.nextInt scane String[] args args
import java.io.IOException;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {

		Scanner scane = new Scanner(System.in);

		int n = 0, x = 0;

		n = scane.nextInt();
		x = scane.nextInt();

		int count =0;


		while ((n+x) != 0) {

			count =0;

			for(int i= n; i>0; --i ){
				for(int j = i-1; j>0; --j){
					for(int t =j-1; t>0; --t){

						if((i+j+t) == x){
							count++;
						}

					}
				}
			}

			System.out.println(count);



			n = scane.nextInt();
			x = scane.nextInt();

		}



	}
}