#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int>> xs(n);
  vector<int> what, what_place;
  int last_t = 0, not_read = 0;
  for (int i = 0; i < q; ++i) {
    int type, info;
    cin >> type >> info;
    --info;
    if (type == 1) {
      ++not_read;
      what_place.push_back(xs[info].size());
      xs[info].push_back(what.size());
      what.push_back(info);
    } else if (type == 2) {
      for (int j : xs[info])
        if (j != -1) {
          what[j] = -1;
          --not_read;
        }
      xs[info].clear();
    } else {
      for (int j = last_t; j <= info; ++j)
        if (what[j] != -1) {
          xs[what[j]][what_place[j]] = -1;
          --not_read;
        }
      last_t = max(info + 1, last_t);
    }
    cout << not_read << endl;
  }
  return 0;
}
