#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 85 - 69;
queue<int> q[maxn];
set<pair<int, int> > s;
int n, qu;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int cnt = 0;
  cin >> n >> qu;
  for (int i = 0; i < qu; i++) {
    int ty, fi;
    cin >> ty >> fi;
    if (ty == 1) {
      fi--;
      q[fi].push(cnt);
      s.insert(make_pair(cnt, fi));
      cnt++;
    } else if (ty == 2) {
      fi--;
      while (((int)(q[fi]).size())) {
        s.erase(make_pair(q[fi].front(), fi));
        q[fi].pop();
      }
    } else {
      while (((int)(s).size()) and s.begin()->first < fi)
        q[s.begin()->second].pop(), s.erase(s.begin());
    }
    cout << ((int)(s).size()) << '\n';
  }
  return 0;
}
