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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		} true {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		} StringTokenizer st=new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) 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 if(n==0 && x==0) {
				break;
			} n==0 && x==0 n==0 n 0 x==0 x 0 {
				break;
			} break; int count=0; count 0 for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			} int a=1; int a=1; a 1 a<=n a n a++ a++ a {
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			} {
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			} for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				} int b=1; int b=1; b 1 b<=n b n b++ b++ b {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				} {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				} for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					} int c=0; int c=0; c 0 c<=n c n c++ c++ c {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					} {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					} if(a+b+c==x && a<b && b<c) {
							count++;
						} a+b+c==x && a<b && b<c a+b+c==x && a<b && b<c a+b+c==x a+b+c a+b+c a b c x a<b a b b<c b c {
							count++;
						} count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			StringTokenizer st=new StringTokenizer(br.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x=Integer.parseInt(st.nextToken());

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

			int count=0;
			for(int a=1;a<=n;a++){
				for(int b=1;b<=n;b++) {
					for(int c=0;c<=n;c++) {
						if(a+b+c==x && a<b && b<c) {
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

