import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  }

} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  }

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  } main {
    Scanner stdin = new Scanner(System.in);

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

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

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    } true {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    } int n = stdin.nextInt(); n stdin.nextInt() stdin.nextInt stdin int x = stdin.nextInt(); x stdin.nextInt() stdin.nextInt stdin if (n == 0 && x == 0) {
        break;
      } n == 0 && x == 0 n == 0 n 0 x == 0 x 0 {
        break;
      } break; List<String> list = new ArrayList<String>(); list new ArrayList<String>() for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      } int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      } {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      } for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        } int j = i + 1; int j = i + 1; j i + 1 i 1 j <= n j n j++ j++ j {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        } {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        } if (i + j >= x) {
            break;
          } i + j >= x i + j i j x {
            break;
          } break; int k = x - i - j; k x - i - j x - i - j x i j if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          } k <= n && k > 0 && k != i && k != j k != i k <= n && k > 0 && k != i && k != j k <= n k n k > 0 k 0 k != i k i k != j k j {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          } int[] arr = { i, j, k }; arr { i, j, k } i j k Arrays.sort(arr) Arrays.sort Arrays arr String s = Arrays.toString(arr); s Arrays.toString(arr) Arrays.toString Arrays arr if (!list.contains(s)) {
              list.add(s);
            } !list.contains(s) list.contains(s) list.contains list s {
              list.add(s);
            } list.add(s) list.add list s System.out.println(list.size()) System.out.println System.out System System.out list.size() list.size list String[] args args public class Main {

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  }

} public class Main {

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  }

} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

    while (true) {
      int n = stdin.nextInt();
      int x = stdin.nextInt();
      if (n == 0 && x == 0) {
        break;
      }

      List<String> list = new ArrayList<String>();
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          if (i + j >= x) {
            break;
          }

          int k = x - i - j;
          if (k <= n && k > 0 && k != i && k != j) {
            int[] arr = { i, j, k };
            Arrays.sort(arr);
            String s = Arrays.toString(arr);
            if (!list.contains(s)) {
              list.add(s);
            }
          }
        }
      }

      System.out.println(list.size());
    }
  }

}