#include <bits/stdc++.h>
using namespace std;
int cnt[300010], a[300010];
int mx[300010];
int main() {
  int N, Q, t, x;
  int tot = 0;
  cin >> N >> Q;
  int st = 0, ed = 0;
  memset(mx, -1, sizeof(mx));
  for (int i = 0; i < Q; i++) {
    scanf("%d%d", &t, &x);
    if (t == 1) {
      cnt[x]++;
      tot++;
      a[ed++] = x;
    }
    if (t == 2) {
      tot -= cnt[x];
      cnt[x] = 0;
      mx[x] = ed - 1;
    }
    if (t == 3) {
      while (st < x) {
        int u = a[st];
        if (st <= mx[u]) {
          st++;
          continue;
        }
        cnt[u]--;
        tot--;
        st++;
      }
    }
    cout << tot << endl;
  }
}
