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