#include <bits/stdc++.h>
using namespace std;
int ar[102];
char inp[100];
char inp2[100];
int p;
int main() {
  memset(ar, -1, sizeof(ar));
  gets(inp);
  int n, m;
  sscanf(inp, "%d%d", &n, &m);
  int cnt = 1;
  for (int i = 0; i < n; i++) {
    gets(inp);
    if (inp[0] == 'd') {
      vector<int> ch;
      for (int t = 0; t < m; t++) {
        if (ar[t] != -1) ch.push_back(ar[t]);
      }
      memset(ar, -1, sizeof(ar));
      int k = 0;
      for (int t = 0; t < m && k < ch.size(); t++, k++) {
        ar[t] = ch[k];
      }
    } else if (inp[0] == 'e') {
      sscanf(inp, "%s%d", inp2, &p);
      bool got = false;
      if (p > 0)
        for (int t = 0; t < m; t++) {
          if (ar[t] == p) {
            ar[t] = -1;
            got = true;
          }
        }
      if (!got) {
        puts("ILLEGAL_ERASE_ARGUMENT");
      }
    } else {
      sscanf(inp, "%s%d", inp2, &p);
      bool perf = false;
      for (int t = 0; t + p <= m; t++) {
        int j = t;
        for (; j < t + p; j++)
          if (ar[j] != -1) break;
        if (j == t + p) {
          j = t;
          for (; j < t + p; j++) ar[j] = cnt;
          perf = true;
          printf("%d\n", cnt);
          cnt++;
          break;
        }
      }
      if (!perf) puts("NULL");
    }
  }
  return 0;
}
