#include <bits/stdc++.h>
using namespace std;
int main() {
  srand(time(NULL));
  int last_t = 0, n, k, m, q, ans = 0;
  cin >> n >> q;
  vector<int> for_type_one;
  vector<set<int>> for_type_two(n + 1);
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 1) {
      int x;
      cin >> x;
      for_type_one.push_back(x);
      for_type_two[x].insert(for_type_one.size() - 1);
      ans++;
    }
    if (type == 2) {
      int x;
      cin >> x;
      ans -= for_type_two[x].size();
      for_type_two[x].clear();
    }
    if (type == 3) {
      int t;
      cin >> t;
      for (int del = last_t; del < t; del++) {
        if (for_type_two[for_type_one[del]].find(del) !=
            for_type_two[for_type_one[del]].end()) {
          for_type_two[for_type_one[del]].erase(
              for_type_two[for_type_one[del]].find(del));
          ans--;
        }
      }
      if (last_t < t) {
        last_t = t;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
