#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long n, q, unread = 0;
  unsigned long a, b;
  cin >> n >> q;
  vector<set<unsigned long>> app(n);
  queue<pair<unsigned long, unsigned long>> qu;
  unsigned long count = 0;
  unsigned long max_t = 0;
  for (unsigned long i = 0; i < q; ++i) {
    cin >> a >> b;
    switch (a) {
      case 1:
        app[b - 1].insert(count);
        ++unread;
        qu.push(make_pair(count, b - 1));
        ++count;
        break;
      case 2:
        unread -= app[b - 1].size();
        app[b - 1].clear();
        break;
      default:
        while (qu.size() > 0 && qu.front().first < b) {
          auto elem = qu.front().first;
          auto j = qu.front().second;
          if (app[j].count(elem)) {
            --unread;
            app[j].erase(elem);
          }
          qu.pop();
        }
    }
    cout << unread << endl;
  }
}
