#include <bits/stdc++.h>
using namespace std;
set<int> a[300010];
set<int> tt;
vector<int> out;
int main() {
  ios_base::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  for (int i = 1, cnt = 1; i <= q; i++) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      tt.insert(cnt);
      a[x].insert(cnt);
      cnt++;
    } else if (t == 2) {
      for (auto y : a[x]) tt.erase(y);
      a[x].clear();
    } else
      tt.erase(tt.begin(), tt.upper_bound(x));
    out.push_back(tt.size());
  }
  for (auto x : out) cout << x << endl;
  return 0;
}
