#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  cin >> n >> q;
  vector<set<long long>> st(n + 5);
  long long k = 0;
  vector<pair<long long, long long>> z;
  long long u = 0;
  map<long long, long long> mp;
  for (long long i = 0; i < q; i++) {
    long long c, d;
    cin >> c >> d;
    if (c == 1) {
      st[d].insert(i);
      u++;
      z.push_back({d, i});
    } else if (c == 2) {
      while (st[d].size()) {
        long long r = *st[d].begin();
        mp[r] = 1;
        st[d].erase(r);
        u--;
      }
    } else {
      for (long long j = k; j < d; j++) {
        if (mp[z[j].second] == 0) {
          mp[z[j].second] = 1;
          if (st[z[j].first].size() > 0) {
            st[z[j].first].erase(z[j].second);
          }
          u--;
        }
      }
      k = max(k, d);
    }
    cout << u << endl;
  }
}
