public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  } run {
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  } java.util.Scanner sc = new java.util.Scanner(in); sc new java.util.Scanner(in) int n n x; x int i i j j k k count; count for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    } ; {
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    } {
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    } n = sc.nextInt() n sc.nextInt() sc.nextInt sc x = sc.nextInt() x sc.nextInt() sc.nextInt sc if(n == 0 && x == 0)break; n == 0 && x == 0 n == 0 n 0 x == 0 x 0 break; count = 0 count 0 for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      } i = 1; i = 1 i 1 i <= n i n i++ i++ i {
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      } {
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      } for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        } j = i + 1; j = i + 1 j i + 1 i 1 j <= n j n j++ j++ j {
          if(x - i - j > j && x - i - j <= n)count++;
        } {
          if(x - i - j > j && x - i - j <= n)count++;
        } if(x - i - j > j && x - i - j <= n)count++; x - i - j > j && x - i - j <= n x - i - j > j x - i - j x - i - j x i j j x - i - j <= n x - i - j x - i - j x i j n count++ count System.out.println(count) System.out.println System.out System System.out count sc.close() sc.close sc java.io.InputStream in in java.io.PrintStream out out public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  } main {
    (new Main()).run(System.in, System.out);
  } (new Main()).run(System.in, System.out) (new Main()).run (new Main()) System.in System System.in System.out System System.out String[] args args public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, x;
    int i, j, k, count;

    for(;;){
      n = sc.nextInt();
      x = sc.nextInt();
      if(n == 0 && x == 0)break;

      count = 0;
      for(i = 1;i <= n;i++){
        for(j = i + 1;j <= n;j++){
          if(x - i - j > j && x - i - j <= n)count++;
        }
      }

      System.out.println(count);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}