import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}
} Main public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	} main {

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		} true {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int y = sc.nextInt(); y sc.nextInt() sc.nextInt sc if(x==0 && y==0) {
				break;
			} x==0 && y==0 x==0 x 0 y==0 y 0 {
				break;
			} break; int a a b b c; c int count = 0; count 0 for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			} int i=1; int i=1; i 1 i<=x i x i++ i++ i {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			} {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			} for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				} int j=i+1; int j=i+1; j i+1 i 1 j<=x j x j++ j++ j {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				} {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				} for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					} int k=j+1; int k=j+1; k j+1 j 1 k<=x k x k++ k++ k {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					} {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					} a = i a i b = j b j c = k c k if(a+b+c==y) {
							count++;
						} a+b+c==y a+b+c a+b+c a b c y {
							count++;
						} count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}
} public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}
} Main
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		while(true) {
			int x = sc.nextInt();
			int y = sc.nextInt();

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

			int a,b,c;
			int count = 0;

			for(int i=1;i<=x;i++) {
				for(int j=i+1;j<=x;j++) {
					for(int k=j+1;k<=x;k++) {
						a = i;
						b = j;
						c = k;
						if(a+b+c==y) {
							count++;
						}
					}
				}
			}

			System.out.println(count);
		}
		sc.close();
	}
}
