import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		} true {
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		} String[] line = br.readLine().split(" "); line br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(line[0]); n Integer.parseInt(line[0]) Integer.parseInt Integer line[0] line 0 int x = Integer.parseInt(line[1]); x Integer.parseInt(line[1]) Integer.parseInt Integer line[1] line 1 int sun = 0; sun 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 j = 1; j <=i ; j++){
					for(int k = 1; k <=j ; k++){
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			} 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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			} {
				for(int j = 1; j <=i ; j++){
					for(int k = 1; k <=j ; k++){
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			} for(int j = 1; j <=i ; j++){
					for(int k = 1; k <=j ; k++){
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					}
				} 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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				} {
					for(int k = 1; k <=j ; k++){
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					}
				} for(int k = 1; k <=j ; k++){
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					} int k = 1; int k = 1; k 1 k <=j k j k++ k++ k {
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					} {
						if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						}
					} if( i+j+k == x && i != j && i != k && j != k ){
							sun++;
						} i+j+k == x && i != j && i != k && j != k i != k i+j+k == x && i != j && i != k && j != k i+j+k == x i+j+k i+j+k i j k x i != j i j i != k i k j != k j k {
							sun++;
						} sun++ sun System.out.println(sun) System.out.println System.out System System.out sun String[] args args public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] line = br.readLine().split(" ");
			int n = Integer.parseInt(line[0]);
			int x = Integer.parseInt(line[1]);
			int sun = 0;
			if( n == 0 && x == 0) break;
			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 && i != j && i != k && j != k ){
							sun++;
						}
					}
				}
			}
			System.out.println(sun);
		}
	}
}