#include <bits/stdc++.h>
int n, m, ans, cnt = 1, par[300050], id = 1;
std::set<int> P[300050];
int main() {
  std::cin >> n >> m;
  for (int j = 1; j <= m; ++j) {
    int t, p;
    std::cin >> t >> p;
    if (t == 1) {
      par[cnt] = p;
      P[p].insert(cnt++);
      ans++;
      std::cout << ans << "\n";
    }
    if (t == 2) {
      ans -= (int)(P[p].size());
      P[p].clear();
      std::cout << ans << "\n";
    }
    if (t == 3) {
      if (id <= p) {
        for (int i = id; i <= p; ++i) {
          if (P[par[i]].count(i)) {
            ans--;
            P[par[i]].erase(i);
          }
        }
        id = p + 1;
      }
      std::cout << ans << "\n";
    }
  }
}
