#include <bits/stdc++.h>
using namespace std;
const int N = 310000;
int bound[N], B[N];
pair<int, int> A[N];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  int unread = 0, sz = 0, cnt = 0;
  while (q--) {
    int i, t, x;
    scanf("%d %d", &t, &x);
    if (t == 1) {
      B[x]++;
      A[sz++] = {x, B[x]};
      unread++;
    }
    if (t == 2) {
      unread -= B[x] - bound[x];
      bound[x] = B[x];
    }
    if (t == 3) {
      for (i = cnt; i < x; i++)
        if (bound[A[i].first] < A[i].second) bound[A[i].first]++, unread--;
      cnt = max(cnt, x);
    }
    printf("%d\n", unread);
  }
}
