#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 1000000009;
double eps = 1e-12;
vector<long long> adj[300005];
multiset<long long> mst;
void solve() {
  long long n, q;
  cin >> n >> q;
  long long idx = 0;
  while (q--) {
    long long type, x, t;
    cin >> type;
    if (type == 1) {
      cin >> x;
      idx++;
      adj[x].push_back(idx);
      mst.insert(idx);
    } else if (type == 2) {
      cin >> x;
      for (auto it : adj[x])
        if (mst.find(it) != mst.end()) mst.erase(it);
      adj[x].clear();
    } else {
      cin >> t;
      while (mst.size() > 0 && *mst.begin() <= t) mst.erase(mst.begin());
    }
    cout << mst.size() << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (int it = 1; it <= t; it++) {
    solve();
  }
  return 0;
}
