#include <bits/stdc++.h>
using namespace std;
int cnt_r[300005];
int cnt[300005];
bool w[300005];
int main() {
  int last = 0;
  vector<int> mess;
  int n, q;
  cin >> n >> q;
  for (int i = 0; i <= n; i++) {
    cnt[i] = 0;
    cnt_r[i] = 0;
    w[i] = 0;
  }
  long long cnt_m = 0;
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 1) {
      mess.push_back(y);
      cnt_m++;
      cnt[y]++;
      cout << cnt_m << endl;
    } else if (x == 2) {
      cnt_m -= cnt[y];
      cnt_r[y] += cnt[y];
      cnt[y] = 0;
      cout << cnt_m << endl;
    } else {
      for (int j = last; j < y; j++) {
        if (w[j]) continue;
        int z = mess[j];
        if (cnt_r[z] == 0) {
          cnt_m--;
          cnt[z]--;
        } else
          cnt_r[z]--;
        w[j] = 1;
      }
      last = max(last, y);
      cout << cnt_m << endl;
    }
  }
  return 0;
}
