#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  register int c = getchar();
  x = 0;
  for (; c < 48 || c > 57; c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) x = (x << 1) + (x << 3) + c - 48;
}
queue<int> y[300005], v;
int main() {
  int n, q, w = 0, x, z = 0, t = 0;
  read(n);
  read(q);
  while (q--) {
    read(x);
    if (x == 1) {
      read(x);
      v.push(x);
      y[x].push(t++);
    } else if (x == 2) {
      read(x);
      z += y[x].size();
      while (!y[x].empty()) y[x].pop();
    } else {
      read(x);
      while (x > w) {
        if (!y[v.front()].empty() && y[v.front()].front() < x) {
          y[v.front()].pop();
          z++;
        }
        ++w;
        v.pop();
      }
    }
    printf("%d\n", t - z);
  }
}
