#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > a(n, make_pair(0, 0));
  int sum = 0;
  vector<pair<int, int> > b;
  vector<pair<int, int> > pr;
  int p = 0;
  for (int i = 0; i < m; i++) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    if (t1 == 1) {
      t2--;
      sum++;
      a[t2].second++;
      pr.push_back(make_pair(t2, a[t2].second));
    }
    if (t1 == 2) {
      t2--;
      sum -= a[t2].second - a[t2].first;
      a[t2].first = a[t2].second;
    }
    if (t1 == 3) {
      for (int j = p; j < t2; j++) {
        int v1 = pr[j].first;
        int v2 = pr[j].second;
        if (a[v1].first < v2) {
          sum--;
          a[v1].first = v2;
        }
      }
      p = max(p, t2);
    }
    printf("%d\n", sum);
  }
  return 0;
}
