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

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

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						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 public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

}

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

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

} main {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

} BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); input new BufferedReader(new InputStreamReader(System.in)) while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        } true {
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        } String input_line = input.readLine(); input_line input.readLine() input.readLine input String[] number = input_line.split(" "); number input_line.split(" ") input_line.split input_line " " int until_num = Integer.parseInt(number[0]); until_num Integer.parseInt(number[0]) Integer.parseInt Integer number[0] number 0 int num_sum = Integer.parseInt(number[1]); num_sum Integer.parseInt(number[1]) Integer.parseInt Integer number[1] number 1 if(until_num ==0&&num_sum==0){
	        	break;
	        } until_num ==0&&num_sum==0 until_num ==0 until_num 0 num_sum==0 num_sum 0 {
	        	break;
	        } break; int count=0; count 0 for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		} int first_num=1; int first_num=1; first_num 1 first_num<=until_num first_num until_num first_num++ first_num++ first_num {
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		} {
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		} for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			} int second_num=first_num+1; int second_num=first_num+1; second_num first_num+1 first_num 1 second_num<=until_num second_num until_num second_num++ second_num++ second_num {
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			} {
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			} for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				} int third_num=second_num+1; int third_num=second_num+1; third_num second_num+1 second_num 1 third_num<=until_num third_num until_num third_num++ third_num++ third_num {
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				} {
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				} int three_sum=first_num+second_num+third_num; three_sum first_num+second_num+third_num first_num+second_num+third_num first_num second_num third_num if(three_sum==num_sum){
						count++;
					} three_sum==num_sum three_sum num_sum {
						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 input = new BufferedReader(new InputStreamReader(System.in));

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

}

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

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

}

}