#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, i, urd = 0, t, x, c, temp = 1;
  cin >> n >> m;
  queue<pair<int, int> > q;
  queue<int> qe[n];
  for (i = 0; i < m; i++) {
    cin >> t;
    if (t == 1) {
      cin >> c;
      qe[c - 1].push(temp);
      urd++;
      q.push(make_pair(temp++, c));
      cout << urd << "\n";
    } else if (t == 2) {
      cin >> c;
      urd -= qe[c - 1].size();
      queue<int> temp;
      swap(qe[c - 1], temp);
      cout << urd << "\n";
    } else {
      cin >> c;
      while (!q.empty() && q.front().first <= c) {
        if (!qe[q.front().second - 1].empty() &&
            qe[q.front().second - 1].front() <= c) {
          urd--;
          qe[q.front().second - 1].pop();
        }
        q.pop();
      }
      cout << urd << "\n";
    }
  }
  return 0;
}
