#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300030;
const int INF = 0x7f7f7f7f;
int cases;
set<int> notice;
vector<int> app[MAXN];
int now;
void add(int type) {
  ++now;
  app[type].push_back(now);
  notice.insert(now);
}
void del_by_app(int type) {
  while (!app[type].empty()) {
    notice.erase(app[type].back());
    app[type].pop_back();
  }
}
void del_kth(int k) {
  while (!notice.empty()) {
    auto it = notice.begin();
    if (*it > k) return;
    notice.erase(it);
  }
}
int main() {
  int n, q, op, x;
  scanf("%d%d", &n, &q);
  while (q--) {
    scanf("%d%d", &op, &x);
    if (op == 1) {
      add(x);
    } else if (op == 2) {
      del_by_app(x);
    } else {
      del_kth(x);
    }
    printf("%lu\n", notice.size());
  }
}
