import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n, x;

    Scanner in = new Scanner(System.in);

    while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    }

  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] arg){
    int n, x;

    Scanner in = new Scanner(System.in);

    while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    }

  }
} Main public static void main(String[] arg){
    int n, x;

    Scanner in = new Scanner(System.in);

    while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    }

  } main {
    int n, x;

    Scanner in = new Scanner(System.in);

    while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    }

  } int n n x; x Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    } true {
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    } n = in.nextInt() n in.nextInt() in.nextInt in x = in.nextInt() x in.nextInt() in.nextInt in if(n == 0 && x == 0) break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; int cnt = 0; cnt 0 for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        } int first = n; int first = n; first n first > 0 first 0 first-- first-- first {
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        } {
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        } for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            } int second = 1; int second = 1; second 1 second < first second first second++ second++ second {
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            } {
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            } int third = x - (first+second); third x - (first+second) x (first+second) first second if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                } first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second third != first third <= n first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second first != second first second third > 0 third 0 third <= n third n third != first third first third != second third second {
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                } cnt++ cnt System.out.println(cnt/3) System.out.println System.out System System.out cnt/3 cnt 3 String[] arg arg
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n, x;

    Scanner in = new Scanner(System.in);

    while(true){
        n = in.nextInt();
        x = in.nextInt();
        
        if(n == 0 && x == 0) break;

        int cnt = 0;
        
        for(int first = n; first > 0; first--){
            for(int second = 1; second < first; second++){
                int third = x - (first+second);
                if( first != second &&
                    third > 0 &&
                    third <= n &&
                    third != first &&
                    third != second){
                    // debug System.out.println("first = " + first + " second = " + second + " third = " + third);
                    cnt++;
                }
                    
            }
        }

        System.out.println(cnt/3);
    }

  }
}