#include <bits/stdc++.h>
using namespace std;
int ans;
const int N = 300007;
vector<pair<int, int> > mas;
int cnt[N], ptr[N];
void solve() {
  int n, q;
  scanf("%d%d", &n, &q);
  int ct = 0;
  while (q--) {
    int ty;
    scanf("%d", &ty);
    if (ty == 1) {
      int x;
      scanf("%d", &x);
      mas.push_back(make_pair(x, cnt[x]));
      ++cnt[x];
      ++ans;
    }
    if (ty == 2) {
      int x;
      scanf("%d", &x);
      ans -= (cnt[x] - ptr[x]);
      ptr[x] = cnt[x];
    }
    if (ty == 3) {
      int t;
      scanf("%d", &t);
      for (int i = ct; i < t; ++i) {
        auto z = mas[i];
        int x = z.first;
        int id = z.second;
        if (id < ptr[x]) continue;
        ++ptr[x];
        --ans;
      }
      ct = max(ct, t);
    }
    printf("%d\n", ans);
  }
}
void testgen() {
  FILE *f = fopen("input.txt", "w");
  srand(time(0));
  fclose(f);
}
int main() {
  solve();
  return 0;
}
