import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	} main {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) List<Integer> n = new ArrayList<Integer>(); n new ArrayList<Integer>() List<Integer> x = new ArrayList<Integer>(); x new ArrayList<Integer>() List<Integer> count = new ArrayList<Integer>(); count new ArrayList<Integer>() for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 } int i=0; int i=0; i 0 i++ i++ i {
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 } {
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 } n.add(i, scan.nextInt()) n.add n i scan.nextInt() scan.nextInt scan x.add(i, scan.nextInt()) x.add x i scan.nextInt() scan.nextInt scan count.add(i, 0) count.add count i 0 if(n.get(i)==0 && x.get(i)==0) break; n.get(i)==0 && x.get(i)==0 n.get(i)==0 n.get(i) n.get n i 0 x.get(i)==0 x.get(i) x.get x i 0 break; for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   } int h=0; int h=0; h 0 h++ h++ h {
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   } {
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   } if(n.get(h)==0 && x.get(h)==0) break; n.get(h)==0 && x.get(h)==0 n.get(h)==0 n.get(h) n.get n h 0 x.get(h)==0 x.get(h) x.get x h 0 break; for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 } int i=1; int i=1; i 1 i<=n.get(h) i n.get(h) n.get n h i++ i++ i {
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 } {
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 } for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 } int j=i; int j=i; j i j<=n.get(h) j n.get(h) n.get n h j++ j++ j {
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 } {
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 } if(i==j)continue; i==j i j continue; for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 } int k=j; int k=j; k j k <= n.get(h) k n.get(h) n.get n h k++ k++ k {
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 } {
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 } if(i==k || j==k)continue; i==k || j==k i==k i k j==k j k continue; if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 ); i+j+k == x.get(h) i+j+k i+j+k i j k x.get(h) x.get x h count.set(h, count.get(h)+1 ) count.set count h count.get(h)+1 count.get(h) count.get count h 1 System.out.println(count.get(h)) System.out.println System.out System System.out count.get(h) count.get count h String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	}

} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	}

}