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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	}
} Main public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuffer sb = new StringBuffer(); sb new StringBuffer() int a = 0; a 0 while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		} true {
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		} String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(input[0]); n Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int x = Integer.parseInt(input[1]); x Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 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=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			} int i=1 ; int i=1 ; i 1 i<=n i n i++ i++ i {
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			} {
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			} for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				} int j=i+1 ; int j=i+1 ; j i+1 i 1 j<=n j n j++ j++ j {
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				} {
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				} for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					} int k=j+1 ; int k=j+1 ; k j+1 j 1 k<=n k n k++ k++ k {
						if( (i+k+j)==x ) a++;
					} {
						if( (i+k+j)==x ) a++;
					} if( (i+k+j)==x ) a++; (i+k+j)==x (i+k+j) i+k+j i k j x a++ a sb.append(Integer.toString(a)).append("\n") sb.append(Integer.toString(a)).append sb.append(Integer.toString(a)) sb.append sb Integer.toString(a) Integer.toString Integer a "\n" a = 0 a 0 System.out.print(sb) System.out.print System.out System System.out sb String[] age age public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	}
} public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		int a = 0;

		while(true){
			String[] input = br.readLine().split(" ");
			int n = Integer.parseInt(input[0]);
			int x = Integer.parseInt(input[1]);

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

			for(int i=1 ; i<=n ; i++ ){
				for(int j=i+1 ; j<=n ; j++ ){
					for(int k=j+1 ; k<=n ; k++ ){
						if( (i+k+j)==x ) a++;
					}
				}
			}
			sb.append(Integer.toString(a)).append("\n");
			a = 0;
		}

		System.out.print(sb);
	}
}