#include <bits/stdc++.h>
using namespace std;
static const double PI = 2 * acos(0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  int readnotifics = 0;
  int notifications = 0;
  vector<vector<int> > apps(N, vector<int>());
  vector<bool> read;
  int notf = 0;
  for (int q = 0; q < (int)(Q); q++) {
    int t, v;
    cin >> t >> v;
    v--;
    if (t == 1) {
      apps[v].push_back(notf++);
      notifications++;
      read.push_back(false);
    } else if (t == 2) {
      for (int i = 0; i < apps[v].size(); i++) {
        if (!read[apps[v][i]]) {
          notifications--;
          read[apps[v][i]] = true;
        }
      }
      apps[v].clear();
    } else {
      while (readnotifics <= v) {
        if (!read[readnotifics]) {
          notifications--;
          read[readnotifics] = true;
        }
        readnotifics++;
      }
    }
    cout << notifications << endl;
  }
  return 0;
}
