#include <bits/stdc++.h>
using namespace std;
int a[300005];
int vi[300005];
int v1[300005];
int v2[300005];
int main() {
  int n, q;
  cin >> n >> q;
  int sum = 0, s = 0, j = 0;
  int type = 0, x = 0;
  int last = 0;
  for (int i = 0; i < q; i++) {
    cin >> type >> x;
    if (type == 1) {
      sum++;
      vi[x]++;
      a[j] = x;
      j++;
    } else if (type == 2) {
      sum = sum - vi[x];
      v1[x] += vi[x];
      vi[x] = 0;
    } else if (type == 3 && last < x) {
      for (int h = last; h < x; h++) {
        int g = a[h];
        v2[g]++;
        if (v2[g] > v1[g]) {
          sum--;
          vi[a[h]]--;
          v1[g]++;
        }
      }
      last = x;
    }
    cout << sum << endl;
  }
  return 0;
}
