import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
} import java.io.*; io.* java class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
} Main public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	} main {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	} BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} catch( IOException e ) {
			System.err.println( e );
		} catch( IOException e ) {
			System.err.println( e );
		} IOException e {
			System.err.println( e );
		} System.err.println( e ) System.err.println System.err System System.err e {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} int[] nx= new int[5]; nx new int[5] 5 int count=0; count 0 String[] tmpArray; tmpArray while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			} true {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			} String str = kb.readLine(); str kb.readLine() kb.readLine kb tmpArray = str.split( " " ) tmpArray str.split( " " ) str.split str " " if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				} "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) "0".equals( tmpArray[0] ) "0".equals "0" tmpArray[0] tmpArray 0 "0".equals( tmpArray[1] ) "0".equals "0" tmpArray[1] tmpArray 1 {
					break;
				} break; for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				} int i=0; int i=0; i 0 i<2 i 2 i++ i++ i {
					nx[i]=Integer.parseInt( tmpArray[i] );
				} {
					nx[i]=Integer.parseInt( tmpArray[i] );
				} nx[i]=Integer.parseInt( tmpArray[i] ) nx[i] nx i Integer.parseInt( tmpArray[i] ) Integer.parseInt Integer tmpArray[i] tmpArray i count=0 count 0 for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				} int i=1; int i=1; i 1 i<=nx[0]-2 i nx[0]-2 nx[0] nx 0 2 i++ i++ i {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				} {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				} for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					} int j=i+1; int j=i+1; j i+1 i 1 j<=nx[0]-1 j nx[0]-1 nx[0] nx 0 1 j++ j++ j {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					} {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					} for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						} int k=j+1; int k=j+1; k j+1 j 1 k<=nx[0] k nx[0] nx 0 k++ k++ k {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						} {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						} if( nx[1] == (i+j+k) ) {
								count++;
							} nx[1] == (i+j+k) nx[1] nx 1 (i+j+k) i+j+k i j k {
								count++;
							} count++ count System.out.println( count ) System.out.println System.out System System.out count String[] args args
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
			int[] nx= new int[5];
			int count=0;
			String[] tmpArray;	
			while( true ) {
				String str = kb.readLine();
				tmpArray = str.split( " " );
				if( "0".equals( tmpArray[0] ) && "0".equals( tmpArray[1] ) ) {
					break;
				}
				for( int i=0; i<2; i++ ) {
					nx[i]=Integer.parseInt( tmpArray[i] );
				}
				
				count=0;
				for( int i=1; i<=nx[0]-2; i++ ) {
					for( int j=i+1; j<=nx[0]-1; j++ ) {
						for( int k=j+1; k<=nx[0]; k++ ) {
							if( nx[1] == (i+j+k) ) {
								count++;
							}
						}
					}				
				}
				System.out.println( count );	
			}
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}