#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
template <typename t>
using V = vector<t>;
template <typename t, size_t s>
using A = array<t, s>;
void print() { cout << '\n'; }
template <typename t, typename... v>
void print(const t& a, const v&... b) {
  cout << a << (sizeof...(b) ? " " : "");
  print(b...);
}
template <typename t>
void print_range(t a, const t& b) {
  while (a != b) cout << (*a++) << ' ';
  cout << '\n';
}
constexpr int nax = 3e5, qax = nax;
int n, q;
V<int> ilo[nax + 1];
set<int> S;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> q;
  int cnt = 1;
  for (int i = 1; i <= q; ++i) {
    int t, v;
    cin >> t >> v;
    if (t == 1) {
      ilo[v].push_back(cnt);
      S.insert(cnt);
    }
    if (t == 2) {
      for (int s : ilo[v])
        if (S.find(s) != S.end()) S.erase(s);
      ilo[v].clear();
    }
    if (t == 3)
      while (not S.empty() and *S.begin() <= v) S.erase(S.begin());
    if (t == 1) ++cnt;
    print(S.size());
  }
}
