#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  vector<vector<int>> app(n);
  vector<bool> vis(q, 0);
  int cur = 0;
  int res = 0;
  int mes = 0;
  for (int it = 0; it < q; it++) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) {
      x--;
      res++;
      app[x].push_back(mes);
      mes++;
    }
    if (t == 2) {
      x--;
      for (int j = (int)(app[x]).size() - 1; j >= 0 && !vis[app[x][j]]; j--) {
        vis[app[x][j]] = 1;
        res--;
      }
    }
    if (t == 3) {
      assert(x <= mes);
      while (cur < x) {
        res -= vis[cur] == 0;
        vis[cur] = 1;
        cur++;
      }
    }
    printf("%d\n", res);
  }
}
