#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};
void file() {}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
}
int main() {
  file();
  fast();
  int n, q;
  cin >> n >> q;
  int idx = 0;
  int ans = 0;
  set<pair<int, int> > num, entrance;
  while (q--) {
    int type, x;
    cin >> type >> x;
    if (type == 1) {
      idx++;
      num.insert({x, idx});
      entrance.insert({idx, x});
    } else if (type == 2) {
      auto it = num.lower_bound({x, -1});
      while (it != num.end() && it->first == x) {
        entrance.erase(entrance.find({it->second, it->first}));
        num.erase(it);
        it = num.lower_bound({x, -1});
      }
    } else {
      auto it = entrance.lower_bound({1, -1});
      while (it != entrance.end() && it->first <= x) {
        num.erase(num.find({it->second, it->first}));
        entrance.erase(it);
        it = entrance.lower_bound({1, -1});
      }
    }
    cout << (int)(num.size()) << "\n";
  }
  return 0;
}
