3 1
erase -1
erase 0
erase -2147483648
 26 25
defragment
erase 1
erase -1560200883
alloc 44
defragment
alloc 75
alloc 22
defragment
erase 4
defragment
alloc 57
alloc 53
erase 4
erase -1639632026
erase -2121605039
erase 3
alloc 51
alloc 65
defragment
erase 2
erase 4
alloc 52
erase 3
defragment
erase -1842529282
erase 3
 12 40
erase 1
alloc 21
alloc 5
alloc 7
defragment
defragment
erase 2
alloc 83
erase 4
defragment
alloc 59
defragment
 44 46
alloc 28
alloc 36
defragment
erase -937404236
alloc 71
defragment
alloc 81
alloc 51
erase 3
defragment
alloc 48
erase 1
defragment
alloc 36
defragment
defragment
erase 1
defragment
defragment
erase -1173350787
alloc 94
erase 5
defragment
erase 9
alloc 98
erase 7
defragment
erase 5
erase 1
defragment
erase 2
defragment
erase 4
defragment
erase 9
alloc 8
defragment
erase 9
defragment
defragment
defragment
erase 1
alloc 70
erase 9
 7 6
alloc 1
alloc 2
alloc 3
erase 1
defragment
erase 3
alloc 4
 47 43
erase 1
alloc 95
alloc 53
erase 2
defragment
alloc 100
erase 4
erase 2
erase -849472053
defragment
erase -638355221
alloc 90
erase 3
erase 2
defragment
alloc 17
erase 5
defragment
erase 6
defragment
erase 3
defragment
defragment
alloc 99
alloc 69
alloc 80
erase 9
erase 5
defragment
erase 7
defragment
alloc 93
defragment
defragment
alloc 25
defragment
alloc 14
erase 8
erase 4
defragment
defragment
alloc 96
erase 9
alloc 63
erase 8
defragment
erase 10
 8 50
alloc 51
defragment
alloc 100
defragment
erase 1
alloc 50
defragment
alloc 50
 6 1
defragment
alloc 10
alloc 1
erase -1
erase 1
erase 1
 26 25
alloc 25
erase 1
alloc 24
erase 2
alloc 23
erase 3
alloc 24
erase 4
alloc 24
erase 5
alloc 21
erase 6
alloc 24
erase 7
alloc 25
erase 8
alloc 25
erase 9
alloc 24
erase 10
alloc 25
erase 11
alloc 25
erase 12
alloc 25
erase 13
 10 10
alloc 10
erase -1
erase 1
alloc 5
erase -1
alloc 5
erase 0
alloc 5
erase 0
alloc 5
 37 74
alloc 11
defragment
erase 1
defragment
erase 2
defragment
alloc 90
erase 3
erase 2
erase 3
erase 1
erase 1
alloc 38
alloc 19
erase 1
erase 3
defragment
alloc 93
erase 5
erase 4
alloc 66
alloc 71
erase 5
defragment
defragment
defragment
defragment
erase 7
alloc 47
erase -95616683
erase 2
alloc 28
alloc 32
erase 11
alloc 50
defragment
defragment
 19 46
alloc 21
erase 2
erase 1
defragment
alloc 4
defragment
defragment
alloc 40
erase 1
defragment
defragment
alloc 68
erase -388966015
alloc 85
alloc 53
erase 4
defragment
alloc 49
alloc 88
 12 10
alloc 6
alloc 2
erase 1
alloc 4
alloc 2
erase 3
alloc 2
alloc 3
alloc 1
alloc 1
alloc 1
alloc 1
 16 10
alloc 10
defragment
defragment
defragment
alloc 10
erase 1
erase 2
alloc 6
defragment
defragment
alloc 4
defragment
defragment
erase 2
defragment
alloc 6
 14 100
alloc 99
alloc 1
alloc 1
erase 2
alloc 1
erase 4
erase 1
alloc 100
alloc 1
alloc 99
defragment
erase 4
alloc 100
alloc 99
 22 9
alloc 9
erase 1
alloc 9
erase 2
alloc 9
erase 3
alloc 9
erase 4
alloc 9
erase 5
alloc 9
erase 6
alloc 9
erase 7
alloc 9
erase 8
alloc 9
erase 9
alloc 9
erase 10
alloc 9
erase 11
 42 98
defragment
defragment
defragment
defragment
defragment
alloc 5
alloc 66
defragment
erase 3
alloc 53
defragment
erase 4
erase 2
alloc 70
erase 3
defragment
defragment
erase 2
erase 3
erase -1327931832
alloc 93
alloc 64
erase 7
erase 6
erase 3
alloc 61
alloc 12
alloc 65
erase 2
alloc 46
erase 11
erase 9
erase 9
erase 6
alloc 2
alloc 78
defragment
erase 13
erase 6
erase 10
alloc 53
alloc 46
 16 10
alloc 10
defragment
defragment
defragment
alloc 10
erase 1
erase 2
alloc 6
defragment
defragment
alloc 4
defragment
defragment
erase 3
defragment
alloc 6
 38 18
alloc 72
erase 2
alloc 50
defragment
erase 3
defragment
alloc 43
alloc 41
defragment
defragment
alloc 26
alloc 46
alloc 16
alloc 15
defragment
defragment
alloc 95
erase 7
erase 7
erase 5
erase 2
erase 9
erase 7
alloc 43
defragment
erase 7
defragment
alloc 48
alloc 77
erase 10
erase 11
alloc 16
alloc 84
erase 1
defragment
alloc 86
defragment
erase 13
 16 49
erase -751005193
defragment
alloc 37
alloc 82
erase 3
erase 1
alloc 80
alloc 51
defragment
alloc 74
erase 1
alloc 91
defragment
defragment
alloc 98
defragment
 22 9
erase 1
alloc 6
alloc 65
erase 1
alloc 87
erase -1638927047
alloc 5
erase 2
alloc 70
defragment
alloc 20
alloc 48
erase -69401977
alloc 20
defragment
erase 7
defragment
erase 9
erase 7
erase 4
defragment
alloc 66
 7 100
alloc 100
erase 2147483647
erase 1
alloc 50
alloc 50
erase 3
erase -2147483648

ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
1
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 ILLEGAL_ERASE_ARGUMENT
1
2
3
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
 1
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
2
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
3
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
 1
2
3
4
 ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
1
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
2
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 NULL
NULL
ILLEGAL_ERASE_ARGUMENT
1
NULL
 NULL
1
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
 1
2
3
4
5
6
7
8
9
10
11
12
13
 1
ILLEGAL_ERASE_ARGUMENT
2
ILLEGAL_ERASE_ARGUMENT
3
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
 1
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
2
3
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
4
5
ILLEGAL_ERASE_ARGUMENT
NULL
 1
ILLEGAL_ERASE_ARGUMENT
2
3
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
 1
2
3
4
5
NULL
6
7
8
9
 1
NULL
ILLEGAL_ERASE_ARGUMENT
2
3
4
 1
2
NULL
3
ILLEGAL_ERASE_ARGUMENT
NULL
4
NULL
NULL
NULL
 1
2
3
4
5
6
7
8
9
10
11
 1
2
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
3
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
4
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
 1
NULL
ILLEGAL_ERASE_ARGUMENT
2
3
NULL
 NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
NULL
1
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
 ILLEGAL_ERASE_ARGUMENT
1
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
NULL
 ILLEGAL_ERASE_ARGUMENT
1
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
2
NULL
NULL
NULL
ILLEGAL_ERASE_ARGUMENT
NULL
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
ILLEGAL_ERASE_ARGUMENT
NULL
 1
ILLEGAL_ERASE_ARGUMENT
2
3
ILLEGAL_ERASE_ARGUMENT

#include <bits/stdc++.h>
using namespace std;
namespace teorNum {
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <typename num>
int sign(num n) {
  return n >= 0 ? 1 : -1;
}
}  // namespace teorNum
namespace geom {
inline bool doubleEqual(double a, double b, double eps = 0.001) {
  return abs(a / b - 1) <= eps;
}
const double pi = std::atan(1.0f) * 4;
class vec {
 public:
  vec() = default;
  vec(int len) : data(len){};
  vec(double x, double y) : data({x, y}){};
  vec(double x, double y, double z) : data({x, y, z}){};
  vec(const vec& temp) : data(temp.data) {}
  vec(const std::initializer_list<double>& list) {
    for (auto& element : list) data.push_back(element);
  }
  friend const vec& operator+(const vec& left);
  friend const vec operator-(const vec& left);
  friend vec& operator+=(vec& left, const vec& right);
  friend vec& operator-=(vec& left, const vec& right);
  friend vec& operator*=(vec& left, const double right);
  friend vec& operator/=(vec& left, const double right);
  friend bool operator==(const vec& left, const vec& right);
  friend bool operator!=(const vec& left, const vec& right);
  double& operator[](int i) { return data[i]; };
  const double& operator[](int i) const { return data[i]; };
  vec& operator=(const vec& right) {
    data = right.data;
    return *this;
  };
  friend const vec operator+(const vec& left, const vec& right);
  friend const vec operator-(const vec& left, const vec& right);
  friend const vec operator*(const vec& left, const double right);
  friend const vec operator*(const double left, const vec& right);
  friend const vec operator/(const vec& left, const double right);
  friend const vec operator/(const double left, const vec& right);
  friend ostream& operator<<(ostream& out, const vec& a);
  friend istream& operator>>(istream& in, vec& a);
  int size() const { return data.size(); };
  double length() const {
    double sum = 0;
    for (int i = 0; i < size(); ++i) sum += (data[i] * data[i]);
    return sqrt(sum);
  }
  double scalarMupltiply(const vec& right) const {
    double ans = 0;
    for (int i = 0; i < size(); ++i) ans += (data[i] * right[i]);
    return ans;
  }
  const vec vectorMultiply(const vec& right) const {
    if (size() != right.size()) throw "Different sizes";
    if (size() < 2 || size() > 3) throw "Wrong size";
    vec a(3), b(3);
    if (size() == 2) {
      a = {data[0], data[1], 0};
      b = {right[0], right[1], 0};
    } else {
      a = *this;
      b = right;
    }
    vec ans(3);
    ans = {a[1] * b[2] - a[2] * b[1], -a[0] * b[2] + a[2] * b[0],
           a[0] * b[1] - a[1] * b[0]};
    return ans;
  }
  double angle() { return acos(scalarMupltiply({1, 0}) / length()); };
  double angleBetweenVectors(const vec& b) {
    return acos(scalarMupltiply(b) / b.length() / length());
  };
  const vec rotate(double angle) {
    return {data[0] * cos(angle) - data[1] * sin(angle),
            data[0] * sin(angle) + data[1] * cos(angle)};
  };

 private:
  vector<double> data;
};
const vec& operator+(const vec& left) { return left; };
const vec operator-(const vec& left) {
  vec temp(left);
  return temp *= -1;
};
vec& operator+=(vec& left, const vec& right) {
  if (left.size() != right.size()) throw "Different sizes";
  for (int i = 0; i < left.size(); ++i) left[i] += right[i];
  return left;
}
vec& operator-=(vec& left, const vec& right) { return left += (-right); };
vec& operator*=(vec& left, const double right) {
  for (int i = 0; i < left.size(); ++i) left[i] *= right;
  return left;
}
vec& operator/=(vec& left, const double right) {
  for (int i = 0; i < left.size(); ++i) left[i] /= right;
  return left;
}
bool operator==(const vec& left, const vec& right) {
  for (int i = 0; i < left.size(); ++i)
    if (!doubleEqual(left[i], right[i])) return 0;
  return 1;
};
bool operator!=(const vec& left, const vec& right) { return !(left == right); }
const vec operator+(const vec& left, const vec& right) {
  vec temp = left;
  return temp += right;
}
const vec operator-(const vec& left, const vec& right) {
  return left + (-right);
}
const vec operator*(const vec& left, const double right) {
  vec temp = left;
  return temp *= right;
}
const vec operator*(const double left, const vec& right) {
  vec temp = right;
  return temp *= left;
}
const vec operator/(const vec& left, const double right) {
  vec temp = left;
  return temp /= right;
}
const vec operator/(const double left, const vec& right) {
  vec temp = right;
  return temp *= left;
}
ostream& operator<<(ostream& out, const vec& a) {
  for (int i = 0; i < a.size(); ++i) out << a[i] << " ";
  return out;
}
istream& operator>>(istream& in, vec& a) {
  for (int i = 0; i < a.size(); ++i) in >> a[i];
  return in;
}
double square(const std::initializer_list<vec>& list) {
  vec ans((list.end() - 1)->vectorMultiply(*list.begin()));
  for (auto iter = list.begin(); iter != list.end() - 1; ++iter)
    ans += (*iter).vectorMultiply(*(iter + 1));
  return ans.length() / 2;
}
}  // namespace geom
using namespace geom;
using namespace teorNum;
void solution() {
  long long t, m;
  cin >> t >> m;
  vector<long long> memory(m + 1, 0);
  memory[0] = 1;
  long long historyCount = 0;
  vector<long long> history(t + 2, -1);
  vector<long long> historyLen(t + 2, -1);
  for (int i = 0; i < t; ++i) {
    string command;
    cin >> command;
    if (command == "defragment") {
      long long start = 1;
      for (int i1 = 1; i1 <= m; ++i1) {
        int i2 = 1;
        if (memory[i1] == 1) {
          for (i2 = 1; i2 <= t; ++i2) {
            if (history[i2] == i1) break;
          }
          for (int i3 = 0; i3 < historyLen[i2]; ++i3) {
            swap(memory[i3 + start], memory[history[i2] + i3]);
          }
          history[i2] = start;
          start += historyLen[i2];
          i1 = start - 1;
        }
      }
      continue;
    }
    long long count;
    cin >> count;
    if (command == "alloc") {
      long long start = 1;
      int i1 = 1;
      for (i1 = 1; i1 <= m; ++i1) {
        if (memory[i1] == 0 && memory[i1 - 1] == 1) start = i1;
        if (memory[i1] == 0 && i1 - start + 1 >= count) {
          for (int i3 = start; i3 < start + count; ++i3) memory[i3] = 1;
          history[++historyCount] = start;
          historyLen[historyCount] = count;
          cout << historyCount << endl;
          break;
        }
        if (memory[i1] == 1) {
          start = 1000;
        }
      }
      if (i1 == m + 1) cout << "NULL" << endl;
    }
    if (command == "erase") {
      if (count < 1 || count >= t) {
        cout << "ILLEGAL_ERASE_ARGUMENT" << endl;
        continue;
      }
      if (history[count] == -1) {
        cout << "ILLEGAL_ERASE_ARGUMENT" << endl;
        continue;
      } else {
        for (int i1 = history[count]; i1 < history[count] + historyLen[count];
             ++i1) {
          memory[i1] = 0;
        }
        history[count] = -1;
        historyLen[count] = -1;
      }
    }
  }
}
int main() { solution(); }
