#include <bits/stdc++.h>
using namespace std;
int q[510001], a[510001], ans, r, i, j, k, n, m, b[510001];
int main() {
  memset(a, 0, sizeof(a));
  r = ans = q[0] = 0;
  memset(b, 0, sizeof(b));
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &j, &k);
    if (j == 1) {
      q[++q[0]] = k;
      ans++;
      a[k]++;
    }
    if (j == 2) {
      b[k] += a[k];
      ans -= a[k];
      a[k] = 0;
    }
    if (j == 3) {
      while (r < k) {
        r++;
        if (b[q[r]])
          b[q[r]]--;
        else
          a[q[r]]--, ans--;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
