
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {	
	    public static void main(String[] args) throws IOException {
	        BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            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 reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            }
	        } 
	    } Main public static void main(String[] args) throws IOException {
	        BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            }
	        } main {
	        BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            }
	        } BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) ); reader new BufferedReader( new InputStreamReader( System.in ) ) int X X Y; Y String[] t; t while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            } true {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            } String str = reader.readLine(); str reader.readLine() reader.readLine reader t= str.split( " " ) t str.split( " " ) str.split str " " int n = Integer.parseInt(t[0] ); n Integer.parseInt(t[0] ) Integer.parseInt Integer t[0] t 0 int x = Integer.parseInt(t[1] ); x Integer.parseInt(t[1] ) Integer.parseInt Integer t[1] t 1 if(n==0 && x==0 ) {  
	                	break; 
	                	} n==0 && x==0 n==0 n 0 x==0 x 0 {  
	                	break; 
	                	} break; int count = 0; count 0 X = x / 3 X x / 3 x 3 int i i j j k; k for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                } i=1; i=1 i 1 i<X i X i++ i++ i {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                } {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                } Y = ( x-i ) / 2 Y ( x-i ) / 2 ( x-i ) x i 2 for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    } j=i+1; j=i+1 j i+1 i 1 j<=Y j Y j++ j++ j {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    } {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    } k = x - i - j k x - i - j x - i - j x i j if( j < k && k <= n ) {
	                            count++;
	                        } j < k && k <= n j < k j k k <= n k n {
	                            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 reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            }
	        } 
	    } public class Main {	
	    public static void main(String[] args) throws IOException {
	        BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            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 reader = new BufferedReader( new InputStreamReader( System.in ) );
	            int X,Y;
	            String[] t;  
	            while( true ) {
	                String str = reader.readLine();
	                t= str.split( " " );
	               int n = Integer.parseInt(t[0] );
	               int x = Integer.parseInt(t[1] );
	                if(n==0 && x==0 ) {  
	                	break; 
	                	}
	                int count = 0;
	                X = x / 3;
	                int i, j, k;
	                for( i=1; i<X; i++ ) {
	                    Y = ( x-i ) / 2;
	                    for( j=i+1; j<=Y; j++ ) {
	                        k = x - i - j;
	                        if( j < k && k <= n ) {
	                            count++;
	                        }
	                    }
	                }
	                System.out.println( count );    
	            }
	        } 
	    }
	
