#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int INF = 100000000;
int vis[300005], d[300005];
int main() {
  int i, j, k, n, sum = 0, ty, o, l = 0;
  vector<int> Q;
  memset(vis, 0, sizeof(vis));
  memset(d, 0, sizeof(d));
  cin >> n >> o;
  for (i = 0; i < o; i++) {
    int p = 0, q;
    scanf("%d%d", &ty, &k);
    if (ty == 1) {
      Q.push_back(k);
      vis[k]++;
      sum++;
    } else if (ty == 2) {
      d[k] += vis[k];
      sum -= vis[k];
      vis[k] = 0;
    } else if (ty == 3) {
      for (j = l; j < k; j++, l++) {
        q = Q[j];
        if (d[q]) {
          d[q]--;
        } else {
          sum--;
          vis[q]--;
        }
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
