import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

} import java.io.*; io.* java public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder keepfile = new StringBuilder(); keepfile new StringBuilder() String[] str; str while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  } true {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  } str = br.readLine().split(" ") str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int n = Integer.parseInt(str[0]); n Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int x = Integer.parseInt(str[1]); x Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		} n == 0 & x == 0 n == 0 n 0 x == 0 x 0 break; if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		} n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300 n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300 n != 0 & x != 0 n != 0 n 0 x != 0 x 0 n >= 3 & n <= 100 n >= 3 n 3 n <= 100 n 100 x >= 0 & x <= 300 x >= 0 x 0 x <= 300 x 300 {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		} int N = 0 ; N 0 for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   } {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   } for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  } int j = (i+1) ; int j = (i+1) ; j (i+1) i 1 j <= n j n j++ j++ j {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  } {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  } int k = 0 ; k 0 k = x-i-j k x-i-j x-i-j x i j if(j < k & k <= n) N++; j < k & k <= n j < k j k k <= n k n N++ N keepfile.append(N).append("\n") keepfile.append(N).append keepfile.append(N) keepfile.append keepfile N "\n" System.out.print(keepfile) System.out.print System.out System System.out keepfile br.close() br.close br String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

} Main
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder keepfile = new StringBuilder();
		
        String[] str;

		while(true) {
	//??\???????????????????????????
		str = br.readLine().split(" ");	
		int n = Integer.parseInt(str[0]);
		int x = Integer.parseInt(str[1]);;
		if(n == 0 & x == 0) break;
		
	//?¨???????????????????????????????	 
		else if(n != 0 & x != 0 | n >= 3 & n <= 100 | x >= 0 & x <= 300) {
			int N = 0 ;         //N ???????¨????x??¨????????????????????????????????°??§???
			for(int i = 1; i <= n ; i++) {
			   for(int j = (i+1) ; j <= n ; j++) {
				   int k = 0 ;
					   k = x-i-j ;         //x = i+j+k ???????????????k=x-i-j ??¨?????????
					   if(j < k & k <= n) N++; 
			  }
			   
		   }
			 keepfile.append(N).append("\n");
		}
		
	  }
		
	//??????????????????????????????
		   System.out.print(keepfile);
	
	   br.close();
	}

}