#include <bits/stdc++.h>
using namespace std;
int un;
queue<int> pos[300002];
queue<pair<int, int> > app;
bool readed[300002];
int main() {
  int n, q, ty, z, i, j, k = 0, in = 1;
  cin >> n >> q;
  for (i = 1; i <= q; i++) {
    scanf("%d %d", &ty, &z);
    if (ty == 1)
      un++, app.push(make_pair(in, z)), pos[z].push(in), in++;
    else if (ty == 2) {
      un -= pos[z].size();
      while (!pos[z].empty()) {
        int p = pos[z].front();
        readed[p] = 1;
        pos[z].pop();
      }
    } else {
      int ii, xx;
      while (!app.empty() && app.front().first <= z) {
        ii = app.front().first, xx = app.front().second;
        app.pop();
        if (readed[ii] == 0) readed[ii] = 1, pos[xx].pop(), un--;
      }
    }
    printf("%d\n", un);
  }
  return 0;
}
