#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  register T c = getchar();
  x = 0;
  int t = 0;
  if (c == '-') t = 1, c = getchar();
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (t) x = -x;
}
int tot;
int main() {
  long long n, q;
  cin >> n >> q;
  long long type, x;
  long long till = 0;
  set<pair<long long, long long> > s;
  map<long long, set<pair<long long, long long> > > make_pair;
  long long i = 1;
  while (q--) {
    cin >> type;
    cin >> x;
    if (type == 1) {
      s.insert({i, x});
      make_pair[x].insert({i, x});
      ++tot;
      ++i;
    } else if (type == 2) {
      for (auto it = make_pair[x].begin(); it != make_pair[x].end(); it++) {
        pair<long long, long long> p = *it;
        if (s.find(p) != s.end()) {
          s.erase(s.find(p));
          --tot;
        }
      }
      make_pair[x].clear();
    } else {
      while (!s.empty()) {
        auto it = s.begin();
        if (it->first <= x) {
          s.erase(it);
          --tot;
        } else
          break;
      }
    }
    cout << tot << endl;
  }
}
