import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	public static void main(String[] args) throws IOException {
		int count = 0;		//?§£????????°
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		}
	}
} import java.io.IOException; IOException java.io import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io class Main {
	public static void main(String[] args) throws IOException {
		int count = 0;		//?§£????????°
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		}
	}
} Main public static void main(String[] args) throws IOException {
		int count = 0;		//?§£????????°
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		}
	} main {
		int count = 0;		//?§£????????°
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		}
	} int count = 0; count 0 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		} !(line.equals("0 0")) (line.equals("0 0")) line.equals line "0 0" {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		} String nums[] = line.split(" "); nums line.split(" ") line.split line " " int max = Integer.parseInt(nums[0]); max Integer.parseInt(nums[0]) Integer.parseInt Integer nums[0] nums 0 int sum = Integer.parseInt(nums[1]); sum Integer.parseInt(nums[1]) Integer.parseInt Integer nums[1] nums 1 for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			} int i = 1 ; int i = 1 ; i 1 i <= max i max i++ i++ i {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			} {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			} for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				} int j = i+1 ; int j = i+1 ; j i+1 i 1 j <= max j max j++ j++ j {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				} {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				} int k = sum - i - j ; k sum - i - j sum - i - j sum i j if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					} k <= j k j {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					} break;	//	??\??????j?????¨??¨?????? if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					} k > max k max {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					} continue; //??\??????j???????????§????????? count++ count System.out.println(count) System.out.println System.out System System.out count line = br.readLine() line br.readLine() br.readLine br count = 0 count 0 String[] args args
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
class Main {
	public static void main(String[] args) throws IOException {
		int count = 0;		//?§£????????°
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        while( !(line.equals("0 0")) ) {
			String nums[] = line.split(" ");
			int max = Integer.parseInt(nums[0]);
			int sum = Integer.parseInt(nums[1]);
			for( int i = 1 ; i <= max ; i++ ) {		//??????????????°???
				for( int j = i+1 ; j <= max ; j++ ) {	//??????????????°???
					int k = sum - i - j ;
					if ( k <= j ) {	//??????????????°??????j????????§??????????????????
						break;	//	??\??????j?????¨??¨??????
					}
					if ( k > max ) {	//??????????????°??????max????????§??????????????????
						continue; //??\??????j???????????§?????????
					}
					count++;
//					System.out.println( i + " " + j + " " + k ) ;
				}
			}
			System.out.println(count);
			line = br.readLine();
			count = 0;
		}
	}
}