#include <bits/stdc++.h>
const int MAXN = (int)3e5 + 10;
std::set<int> tasks;
std::queue<int> a[MAXN];
int main(void) {
  int n, q;
  scanf("%d%d", &n, &q);
  int cur = 1, answer = 0;
  for (int i = 0; i < q; ++i) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) {
      tasks.insert(cur);
      a[x].push(cur);
      ++cur;
    } else if (t == 2) {
      while (!a[x].empty()) {
        tasks.erase(a[x].front());
        a[x].pop();
      }
    } else {
      while (!tasks.empty() && *tasks.begin() <= x) {
        tasks.erase(tasks.begin());
      }
    }
    printf("%d\n", tasks.size());
  }
  return 0;
}
