import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  } main {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    } true {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    } int n = in.nextInt(); n in.nextInt() in.nextInt in int 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 count = 0; count 0 for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      } int i = 1; int i = 1; i 1 i < (double)x / 3 i (double)x / 3 (double)x 3 i++ i++ i {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      } {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      } for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        } int j = i + 1; int j = i + 1; j i + 1 i 1 j < (double)(x - i) / 2 j (double)(x - i) / 2 (double)(x - i) x i 2 j++ j++ j {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        } {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        } if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          } x - (i + j) > n x - (i + j) x (i + j) i j n {
            continue;
          } continue; {
            count += (x - i - 2 * j + 1) / 2;
            break;
          } count += (x - i - 2 * j + 1) / 2 count (x - i - 2 * j + 1) / 2 (x - i - 2 * j + 1) x - i - 2 * j x - i - 2 * j x i 2 * j 2 j 1 2 break; 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) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    while(true) {
      int n = in.nextInt();
      int x = in.nextInt();

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

      int count = 0;
      for (int i = 1; i < (double)x / 3; i++) {
        for (int j = i + 1; j < (double)(x - i) / 2; j++) {
          if (x - (i + j) > n) {
            continue;
          }
          else {
            count += (x - i - 2 * j + 1) / 2;
            break;
          }
        }
      }
      System.out.println(count);
    }
  }
}