#include <bits/stdc++.h>
using namespace std;
struct O {
  bool read = false;
  int app;
  O(int a) : app(a) {}
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Q, unreadFirst = 0;
  cin >> N >> Q;
  vector<queue<int> > APPS(N + 1);
  vector<O> nots;
  int unread = 0;
  for (int x = 0; x < Q; x++) {
    int q;
    cin >> q;
    if (q == 1) {
      int app;
      cin >> app;
      nots.push_back(O(app));
      APPS[app].push((int)nots.size() - 1);
      unread++;
    } else if (q == 2) {
      int app;
      cin >> app;
      while (!APPS[app].empty())
        nots[APPS[app].front()].read = true, unread--, APPS[app].pop();
    } else {
      int t;
      cin >> t;
      while (unreadFirst < t) {
        if (!nots[unreadFirst].read) {
          APPS[nots[unreadFirst].app].pop();
          nots[unreadFirst].read = true;
          unread--;
        }
        unreadFirst++;
      }
    }
    cout << unread << '\n';
  }
}
