#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  vector<vector<int>> ah(n + 1);
  vector<int> h, vis(q);
  int unread = 0, l = 0, t = 0;
  while (q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int a;
      cin >> a;
      ++unread;
      h.push_back(a);
      ah[a].push_back(t);
      ++t;
    } else if (op == 2) {
      int a;
      cin >> a;
      auto& ch = ah[a];
      for (auto i : ch) {
        if (!vis[i]) {
          --unread;
          vis[i] = 1;
        }
      }
      ch.clear();
    } else {
      int x;
      cin >> x;
      while (l < x) {
        if (!vis[l]) {
          --unread;
        }
        vis[l] = 1;
        ++l;
      }
    }
    cout << unread << '\n';
  }
  return 0;
}
