import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

class Main{

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		}

		System.out.print(sb);

	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io import java.util.StringTokenizer; StringTokenizer java.util class Main{

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		}

		System.out.print(sb);

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		}

		System.out.print(sb);

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		}

		System.out.print(sb);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() while(true){

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		} true {

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		} String input = br.readLine(); input br.readLine() br.readLine br StringTokenizer st = new StringTokenizer(input, " "); st new StringTokenizer(input, " ") int n = Integer.parseInt(st.nextToken()); n Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int x = Integer.parseInt(st.nextToken()); x Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st int count = 0; count 0 if(n == 0 && x == 0){
				break;
			} n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
				break;
			} break; for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			} {
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			} for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				} int j = 1; int j = 1; j 1 j <= n j n j++ j++ j {

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				} {

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				} if(j == i){
						break;
					} j == i j i {
						break;
					} break; for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					} int k = 1; int k = 1; k 1 k <= n k n k++ k++ k {

						if(k == i || k == j){
							break;
						}

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

					} {

						if(k == i || k == j){
							break;
						}

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

					} if(k == i || k == j){
							break;
						} k == i || k == j k == i k i k == j k j {
							break;
						} break; if((i + j + k) == x){
							count++;
						} (i + j + k) == x (i + j + k) i + j + k i j k x {
							count++;
						} count++ count sb.append(count + "\n") sb.append sb count + "\n" count "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

class Main{

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			StringTokenizer st = new StringTokenizer(input, " ");
			int n = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int count = 0;

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

			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= n; j++){

					if(j == i){
						break;
					}

					for(int k = 1; k <= n; k++){

						if(k == i || k == j){
							break;
						}

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

					}

				}
			}

			sb.append(count + "\n");

		}

		System.out.print(sb);

	}
}