#include <bits/stdc++.h>
using namespace std;
int x[300100], r[300100];
vector<int> s;
vector<int> m;
int n, q;
int main() {
  cin >> n >> q;
  int ok = 0, lastr = 0;
  int cnt = 0;
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      x[b]++;
      s.push_back(b);
      m.push_back(x[b]);
      cnt++;
    }
    if (a == 2) {
      ok += x[b] - r[b];
      r[b] = x[b];
    }
    if (a == 3) {
      if (b > lastr) {
        for (int i = lastr; i < b; ++i) {
          if (m[i] > r[s[i]]) {
            ok++;
            r[s[i]]++;
          }
        }
        lastr = b;
      }
    }
    cout << cnt - ok << endl;
  }
  return 0;
}
