#include <bits/stdc++.h>
const int maxn = 300010;
int n, m, cnt, go_far;
int not_read[maxn], clr[maxn];
int a[maxn];
int main() {
  int i, op, x, t, zz;
  scanf("%d%d", &n, &m);
  cnt = 0;
  a[0] = 0;
  go_far = 0;
  for (zz = 1; zz <= m; zz++) {
    scanf("%d%d", &op, &x);
    if (op == 1) {
      a[++a[0]] = x;
      cnt++;
      not_read[x]++;
    } else if (op == 2) {
      cnt -= not_read[x];
      clr[x] += not_read[x];
      not_read[x] = 0;
    } else {
      t = x;
      for (i = go_far + 1; i <= t; i++) {
        x = a[i];
        if (clr[x])
          clr[x]--;
        else
          cnt--, not_read[x]--;
      }
      if (t > go_far) go_far = t;
    }
    printf("%d\n", cnt);
  }
}
