#include <bits/stdc++.h>
using namespace std;
int v[300000 + 1], ultcit[300000 + 1];
struct qu {
  int pos, timp;
} que[300000 + 1];
int main() {
  int n, q, i, type, x, m, total, ind;
  m = total = 0;
  ind = 1;
  scanf("%d%d", &n, &q);
  for (i = 1; i <= q; i++) {
    scanf("%d%d", &type, &x);
    if (type == 1) {
      que[++m] = {x, i};
      ++total;
      v[x]++;
    } else if (type == 2) {
      total -= v[x];
      ultcit[x] = i;
      v[x] = 0;
    } else {
      while (ind <= x && ind <= m) {
        if (ultcit[que[ind].pos] < que[ind].timp) {
          --total;
          v[que[ind].pos]--;
        }
        ++ind;
      }
    }
    printf("%d\n", total);
  }
  return 0;
}
