import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> NN = new ArrayList<Integer>();
		ArrayList<Integer> XX = new ArrayList<Integer>();
		int n=1;
		int x=1;
		int kumi =0;
		while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		}
	}
} import java.io.IOException; IOException java.io import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> NN = new ArrayList<Integer>();
		ArrayList<Integer> XX = new ArrayList<Integer>();
		int n=1;
		int x=1;
		int kumi =0;
		while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		}
	}
} Main public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> NN = new ArrayList<Integer>();
		ArrayList<Integer> XX = new ArrayList<Integer>();
		int n=1;
		int x=1;
		int kumi =0;
		while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		}
	} main {
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> NN = new ArrayList<Integer>();
		ArrayList<Integer> XX = new ArrayList<Integer>();
		int n=1;
		int x=1;
		int kumi =0;
		while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) ArrayList<Integer> NN = new ArrayList<Integer>(); NN new ArrayList<Integer>() ArrayList<Integer> XX = new ArrayList<Integer>(); XX new ArrayList<Integer>() int n=1; n 1 int x=1; x 1 int kumi =0; kumi 0 while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		} n != 0 || x!= 0 n != 0 n 0 x!= 0 x 0 {
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		} n =scan.nextInt() n scan.nextInt() scan.nextInt scan x =scan.nextInt() x scan.nextInt() scan.nextInt scan NN.add(n) NN.add NN n XX.add(x) XX.add XX x for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		} int i=0; int i=0; i 0 i<NN.size()-1 i NN.size()-1 NN.size() NN.size NN 1 i++ i++ i {
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		} {
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		} kumi = 0 kumi 0 for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			} int i1=0; int i1=0; i1 0 i1<NN.get(i) i1 NN.get(i) NN.get NN i i1++ i1++ i1 {
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			} {
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			} for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				} int i2=0; int i2=0; i2 0 i2<NN.get(i) i2 NN.get(i) NN.get NN i i2++ i2++ i2 {
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				} {
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				} for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					} int i3=0; int i3=0; i3 0 i3<NN.get(i) i3 NN.get(i) NN.get NN i i3++ i3++ i3 {
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					} {
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					} int N1 = i1+1; N1 i1+1 i1 1 int N2 = i2+1; N2 i2+1 i2 1 int N3 = i3+1; N3 i3+1 i3 1 if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						} N1 == N2 || N2 == N3 || N3 == N1 N1 == N2 || N2 == N3 || N3 == N1 N1 == N2 N1 N2 N2 == N3 N2 N3 N3 == N1 N3 N1 {
							//???????????????
							//System.out.println("T");
						} {
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						} if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							} N1+N2+N3 == XX.get(i) N1+N2+N3 N1+N2+N3 N1 N2 N3 XX.get(i) XX.get XX i {
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							} kumi += 1 kumi 1 System.out.println(kumi/6) System.out.println System.out System System.out kumi/6 kumi 6 String[] args args
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.print(" ");
		Scanner scan = new Scanner(System.in);
		ArrayList<Integer> NN = new ArrayList<Integer>();
		ArrayList<Integer> XX = new ArrayList<Integer>();
		int n=1;
		int x=1;
		int kumi =0;
		while(n != 0 || x!= 0){
			n =scan.nextInt();
			x =scan.nextInt();
			NN.add(n);
			XX.add(x);
//			System.out.println("scaning");
		}
//		System.out.println("finir");
		for (int i=0;i<NN.size()-1;i++){
				kumi = 0;
			for(int i1=0;i1<NN.get(i);i1++){
				for(int i2=0;i2<NN.get(i);i2++){
					for(int i3=0;i3<NN.get(i);i3++){
						int N1 = i1+1;
						int N2 = i2+1;
						int N3 = i3+1;
//						System.out.println(N1 +" "+ N2 +" "+ N3);
						if( N1 == N2 || N2 == N3 || N3 == N1){
							//???????????????
							//System.out.println("T");
						}
						else{
							if(N1+N2+N3 == XX.get(i)){
								kumi += 1;
//								System.out.println(N1+N2+N3);
//								System.out.println(XX.get(i));
							}

						}
					}
				}
			}
			System.out.println(kumi/6);
		}
	}
}