#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, t, tt, x, c = 1;
  cin >> n >> q;
  map<int, int> order;
  unordered_map<int, set<int> > times;
  long long int sum = 0;
  while (q--) {
    cin >> t;
    if (t == 1) {
      cin >> x;
      sum++;
      times[x].insert(c);
      order[c] = x;
      c++;
      cout << sum << endl;
    } else if (t == 2) {
      cin >> x;
      for (auto i : times[x]) {
        order.erase(i);
        sum--;
      }
      times.erase(x);
      cout << sum << endl;
    } else {
      cin >> tt;
      while (!order.empty() && order.begin()->first <= tt) {
        times[order.begin()->second].erase(order.begin()->first);
        order.erase(order.begin()->first);
        sum--;
      }
      cout << sum << endl;
    }
  }
}
