#include <bits/stdc++.h>
using namespace std;
queue<int> q[300005];
set<int> all;
int main() {
  int n, quer;
  scanf("%d%d", &n, &quer);
  int t, x, v;
  int in = 1;
  for (int i = 1; i <= quer; i++) {
    scanf("%d%d", &t, &x);
    if (t == 1) {
      q[x].push(in);
      all.insert(in);
      in++;
    } else if (t == 2) {
      while (!q[x].empty()) {
        all.erase(q[x].front());
        q[x].pop();
      }
    } else {
      while (all.size() >= 1) {
        v = *all.begin();
        if (v <= x)
          all.erase(v);
        else
          break;
      }
    }
    printf("%d\n", all.size());
  }
}
