import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
            int n, x, count, tmp3, tmp2;
            String[] tmpArray;  
            while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            }
        } 
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
            int n, x, count, tmp3, tmp2;
            String[] tmpArray;  
            while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            }
        } 
} Main public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
            int n, x, count, tmp3, tmp2;
            String[] tmpArray;  
            while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            }
        } main {
        Scanner scan = new Scanner( System.in );
            int n, x, count, tmp3, tmp2;
            String[] tmpArray;  
            while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            }
        } Scanner scan = new Scanner( System.in ); scan new Scanner( System.in ) int n n x x count count tmp3 tmp3 tmp2; tmp2 String[] tmpArray; tmpArray while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            } true {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            } String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan 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; count = 0 count 0 tmp3 = x / 3 tmp3 x / 3 x 3 int i i j j k; k for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                } i=1; i=1 i 1 i<tmp3 i tmp3 i++ i++ i {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                } {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                } tmp2 = ( x-i ) / 2 tmp2 ( x-i ) / 2 ( x-i ) x i 2 for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    } j=i+1; j=i+1 j i+1 i 1 j<=tmp2 j tmp2 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
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
            int n, x, count, tmp3, tmp2;
            String[] tmpArray;  
            while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            }
        } 
}
