#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, a, b;
  cin >> n >> q;
  vector<set<int> > s(n + 1);
  set<int>::iterator it;
  vector<int> v;
  int ans = 0, l = 0, cnt = 1;
  for (int i = 1; i <= q; i++) {
    cin >> a >> b;
    if (a == 1) {
      s[b].insert(cnt);
      cnt++;
      v.push_back(b);
      ans++;
    } else if (a == 2) {
      it = s[b].begin();
      while (it != s[b].end()) {
        s[b].erase(it);
        ans--;
        it = s[b].begin();
      }
    } else {
      for (int i = l; i < b; i++) {
        if (s[v[i]].count(i + 1) == 1) {
          ans--;
          s[v[i]].erase(i + 1);
        }
      }
      l = max(l, b);
    }
    cout << ans << '\n';
  }
  return 0;
}
