#include <bits/stdc++.h>
using namespace std;
queue<pair<int, pair<int, set<pair<int, int> >::iterator> > > notviewed[300002];
set<pair<int, int> > general;
pair<int, int> app(int a, int b) { return make_pair(a, b); }
pair<int, pair<int, set<pair<int, int> >::iterator> > appIt(
    int a, int b, set<pair<int, int> >::iterator it) {
  return make_pair(a, make_pair(b, it));
}
int main(int argc, char const *argv[]) {
  int n, q;
  cin >> n >> q;
  int c = 0;
  int id = 0;
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      id++;
      int x;
      cin >> x;
      set<pair<int, int> >::iterator it = general.insert(app(id, x)).first;
      notviewed[x].push(appIt(id, x, it));
      c++;
    } else if (type == 2) {
      int x;
      cin >> x;
      while (!notviewed[x].empty()) {
        int cid = notviewed[x].front().first;
        int capp_id = notviewed[x].front().second.first;
        set<pair<int, int> >::iterator it = notviewed[x].front().second.second;
        notviewed[x].pop();
        general.erase(it);
        c--;
      }
    } else if (type == 3) {
      int t;
      cin >> t;
      while (general.size() > 0) {
        int cid = general.begin()->first;
        int capp_id = general.begin()->second;
        if (cid > t) break;
        general.erase(general.begin());
        notviewed[capp_id].pop();
        c--;
      }
    }
    cout << c << '\n';
  }
  return 0;
}
