#include <bits/stdc++.h>
using namespace std;
vector<int> apps[300000];
set<int> nots;
set<int>::iterator it;
int main() {
  int a, q;
  cin >> a >> q;
  int pos = 0;
  for (int i = 0; i < q; i++) {
    int t, e;
    cin >> t >> e;
    if (t == 1) {
      apps[e].push_back(pos);
      nots.insert(pos);
      pos++;
    }
    if (t == 2) {
      int s = apps[e].size();
      for (int j = 0; j < s; j++) {
        if (nots.find(apps[e][j]) != nots.end())
          nots.erase(nots.find(apps[e][j]));
      }
      apps[e].clear();
    } else if (t == 3) {
      vector<int> tmp;
      it = nots.begin();
      while (it != nots.end() && *it < e) {
        tmp.push_back(*it);
        ++it;
      }
      for (int j = 0; j < tmp.size(); j++) nots.erase(nots.find(tmp[j]));
      tmp.clear();
    }
    cout << nots.size() << endl;
  }
  return 0;
}
