#include <bits/stdc++.h>
using namespace std;
queue<int> app_unread[300001];
int events[300001];
int main(int argc, char const *argv[]) {
  int n, q, unread = 0, last_t = 0, total_t = 0;
  cin >> n >> q;
  for (int i = 0; i < q; ++i) {
    int t, val;
    cin >> t >> val;
    if (t == 1) {
      unread++;
      events[total_t] = val;
      app_unread[val].push(total_t);
      total_t++;
    } else if (t == 2) {
      while (!app_unread[val].empty()) {
        unread--;
        app_unread[val].pop();
      }
    } else {
      for (int j = last_t; j < val; ++j) {
        if ((!app_unread[events[j]].empty()) &&
            app_unread[events[j]].front() == j) {
          app_unread[events[j]].pop();
          unread--;
        }
      }
      last_t = max(val, last_t);
    }
    cout << unread << endl;
  }
  return 0;
}
