#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, q, type, x, sum = 0, cnt = 0, tempos = 1;
  cin >> n >> q;
  int num[300005], meg[300005], pos[300005], nex[300005], curpos[300005];
  for (int i = 0; i < q; i++) {
    cin >> type >> x;
    if (type == 1) {
      num[x]++;
      sum++;
      meg[++cnt] = x;
      if (!pos[x]) {
        pos[x] = cnt;
      } else {
        nex[curpos[x]] = cnt;
      }
      curpos[x] = cnt;
    } else if (type == 2) {
      sum -= num[x];
      num[x] = pos[x] = 0;
    } else {
      for (int j = tempos; j <= x; j++) {
        if ((pos[meg[j]]) && (pos[meg[j]] <= j)) {
          num[meg[j]]--;
          sum--;
          pos[meg[j]] = nex[j];
        }
      }
      tempos = max(x + 1, tempos);
    }
    cout << sum << "\n";
  }
  return 0;
}
