#include <bits/stdc++.h>
using namespace std;
set<int> arr, app[300005];
int arr2app[300005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q, c2 = 1;
  cin >> n >> q;
  for (int c1 = 1; c1 < q + 1; c1++) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      arr.insert(c2);
      app[b].insert(c2);
      arr2app[c2] = b;
      c2++;
    } else if (a == 2) {
      for (auto x : app[b]) {
        arr.erase(x);
      }
      app[b].clear();
    } else {
      while (int(arr.size()) && *(arr.begin()) <= b) {
        app[arr2app[*(arr.begin())]].erase(*(arr.begin()));
        arr.erase(arr.begin());
      }
    }
    cout << int(arr.size()) << '\n';
  }
  return 0;
}
