#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<int> app(1), cnt(n + 1), total(n + 1), unread(n + 1);
  int last = 0, ans = 0;
  for (int i = 0; i < int(q); i++) {
    int t, first;
    cin >> t >> first;
    if (t == 1) {
      app.push_back(first);
      total[first]++;
      unread[first]++;
      ans++;
    } else if (t == 2) {
      ans -= unread[first];
      unread[first] = 0;
    } else {
      for (int j = (last + 1); j < int(first + 1); j++) {
        if (cnt[app[j]] + unread[app[j]] == total[app[j]]) {
          ans--;
          unread[app[j]]--;
        }
        cnt[app[j]]++;
      }
      last = max(last, first);
    }
    cout << ans << "\n";
  }
  return 0;
}
