#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> v[n + 5];
  vector<pair<int, bool> > vv;
  int u = 0, temp = 0, i = 0;
  while (q--) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      u++;
      v[x].push_back(i);
      vv.push_back(make_pair(x, false));
      i++;
    } else if (t == 2) {
      for (int j = 0; j < v[x].size(); j++) {
        int lol = v[x][j];
        if (vv[lol].second == false) {
          vv[lol].second = true;
          u--;
        }
      }
      v[x].clear();
    } else {
      for (int j = temp; j < x; j++) {
        if (vv[j].second == false) {
          vv[j].second = true;
          u--;
        }
      }
      temp = max(temp, x);
    }
    cout << u << '\n';
  }
  return 0;
}
