#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
int n, q, a, b, ctr = 0, x;
vector<int> v[N], v1;
int main() {
  cin >> n >> q;
  while (q--) {
    cin >> a >> b;
    if (a == 1) {
      ctr++;
      v[b].push_back(v1.size());
      v1.push_back(1);
    }
    if (a == 2) {
      for (int i = 0; i < v[b].size(); i++)
        if (v1[v[b][i]]) v1[v[b][i]] = 0, ctr--;
      v[b].clear();
    }
    if (a == 3) {
      for (int i = x; i < b; i++) {
        if (v1[i]) {
          ctr--;
          v1[i] = 0;
        }
      }
      x = max(b, x);
    }
    printf("%d\n", ctr);
  }
  return 0;
}
