#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
queue<int> app[N + 5];
int fn[N + 5], k;
int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += fn[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int val) {
  while (i <= N) {
    fn[i] += val;
    i += i & -i;
  }
}
int main() {
  int n, q, left = 0;
  cin >> n >> q;
  for (int i = 1; i <= q; i++) {
    int type, x;
    cin >> type >> x;
    if (type == 1) {
      app[x].push(++k);
      add(k, 1);
    } else if (type == 2)
      while (!app[x].empty()) {
        int now = app[x].front();
        if (now > left) add(now, -1);
        app[x].pop();
      }
    else
      left = max(left, x);
    cout << sum(k) - sum(left) << "\n";
  }
}
