#include <bits/stdc++.h>
using namespace std;
int n, q, sum = 0, a[300100], x[300100] = {-1}, b[300100] = {0}, s = 0, e = 0,
          tp, t;
void upd(int x, int v) {
  sum += v - b[x];
  b[x] = v;
}
int get() { return (sum); }
int main() {
  cin >> n;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> tp >> t;
    if (tp == 1) {
      upd(t, b[t] + 1);
      a[e] = t;
      if (x[t] == -1) x[t] = e;
      e++;
      cout << get() << endl;
    }
    if (tp == 2) {
      upd(t, 0);
      x[t] = -1;
      cout << get() << endl;
    }
    if (tp == 3) {
      for (int j = s; j < t; ++j)
        if ((x[a[j]] != -1) && (x[a[j]] <= j)) {
          x[a[j]] = j + 1;
          upd(a[j], b[a[j]] - 1);
        }
      s = max(t, s);
      cout << get() << endl;
    }
  }
  return (0);
}
