import java.io.*;

class Main {
	public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	     
			int n, x;
			int cnt, ave3, ave2;
			String[] tmpArray;  
			while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        }
	    } 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 n, x;
			int cnt, ave3, ave2;
			String[] tmpArray;  
			while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        }
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
} Main public static void main(String[] args) {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	     
			int n, x;
			int cnt, ave3, ave2;
			String[] tmpArray;  
			while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        }
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	} main {
	    BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
	    try {
	     
			int n, x;
			int cnt, ave3, ave2;
			String[] tmpArray;  
			while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        }
	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	} BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) ); kb new BufferedReader( new InputStreamReader( System.in ) ) try {
	     
			int n, x;
			int cnt, ave3, ave2;
			String[] tmpArray;  
			while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        }
	    } 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 n, x;
			int cnt, ave3, ave2;
			String[] tmpArray;  
			while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        }
	    } int n n x; x int cnt cnt ave3 ave3 ave2; ave2 String[] tmpArray; tmpArray while( true ) {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        } true {
			    String str = kb.readLine();
			    tmpArray = str.split( " " );
			    n = Integer.parseInt( tmpArray[0] );
			    x = Integer.parseInt( tmpArray[1] );
			
			    if( 0 == n && 0 == x ) {  break; }
			
			    cnt = 0;
			    ave3 = x / 3;
			    int i, j, k;
	            for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            }
	            System.out.println( cnt );    
	        } String str = kb.readLine(); str kb.readLine() kb.readLine kb tmpArray = str.split( " " ) tmpArray str.split( " " ) str.split str " " n = Integer.parseInt( tmpArray[0] ) n Integer.parseInt( tmpArray[0] ) Integer.parseInt Integer tmpArray[0] tmpArray 0 x = Integer.parseInt( tmpArray[1] ) x Integer.parseInt( tmpArray[1] ) Integer.parseInt Integer tmpArray[1] tmpArray 1 if( 0 == n && 0 == x ) {  break; } 0 == n && 0 == x 0 == n 0 n 0 == x 0 x {  break; } break; cnt = 0 cnt 0 ave3 = x / 3 ave3 x / 3 x 3 int i i j j k; k for( i=1; i<ave3; i++ ) {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            } i=1; i=1 i 1 i<ave3 i ave3 i++ i++ i {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            } {
					ave2 = ( x-i ) / 2;
					for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					}
	            } ave2 = ( x-i ) / 2 ave2 ( x-i ) / 2 ( x-i ) x i 2 for( j=i+1; j<=ave2; j++ ) {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					} j=i+1; j=i+1 j i+1 i 1 j<=ave2 j ave2 j++ j++ j {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					} {
						k = x - i - j;
					    if( j < k && k <= n ) {
					        cnt++;
					    }
					} k = x - i - j k x - i - j x - i - j x i j if( j < k && k <= n ) {
					        cnt++;
					    } j < k && k <= n j < k j k k <= n k n {
					        cnt++;
					    } cnt++ cnt System.out.println( cnt ) System.out.println System.out System System.out cnt String[] args args
import java.io.*;

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