#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 4;
struct Message {
  int num, app;
  Message() {}
  Message(int num, int app) : num(num), app(app) {}
};
int App[maxn], cnt[maxn];
int C[maxn];
int n, q;
Message Noti[maxn];
int main() {
  scanf("%d%d", &n, &q);
  int pointer = 0;
  int d = 0;
  int ans = 0;
  while (q--) {
    int t, v;
    scanf("%d%d", &t, &v);
    if (t == 1) {
      App[v]++;
      C[v]++;
      ans++;
      Noti[d++] = Message(C[v], v);
      printf("%d\n", ans);
    } else if (t == 2) {
      cnt[v] = C[v];
      ans -= App[v];
      App[v] = 0;
      printf("%d\n", ans);
    } else if (t == 3) {
      v -= pointer;
      while (v > 0) {
        v--;
        if (Noti[pointer].num > cnt[Noti[pointer].app]) {
          App[Noti[pointer].app]--;
          ans--;
          cnt[Noti[pointer].app] = Noti[pointer].num;
        }
        pointer++;
      }
      printf("%d\n", ans);
    }
  }
}
