#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, i, a, iter, x, type, t, tmax, ans, j, notifCount, app, ind;
  vector<int> index2;
  vector<int>::iterator lb;
  vector<pair<int, int> > notif;
  vector<vector<int> > notifIndex(300002);
  ans = 0;
  notifCount = 0;
  tmax = -1;
  cin >> n >> q;
  for (i = 0; i <= n; i++) {
    index2.push_back(-1);
  }
  for (iter = 1; iter <= q; iter++) {
    cin >> type >> x;
    if (type == 1) {
      notif.push_back(make_pair(x, 0));
      notifIndex[x].push_back(notifCount);
      ans++;
      notifCount++;
    } else if (type == 2) {
      for (j = index2[x] + 1; j < notifIndex[x].size(); j++) {
        if (notif[notifIndex[x][j]].first == x) {
          if (notif[notifIndex[x][j]].second == 0) {
            ans--;
            notif[notifIndex[x][j]].second = 1;
          }
        }
      }
      index2[x] = notifIndex[x].size() - 1;
    } else {
      t = x - 1;
      if (tmax < t) {
        for (i = tmax + 1; i <= t; i++) {
          if (notif[i].second == 0) {
            app = notif[i].first;
            if (index2[app] < i) {
              lb = lower_bound(notifIndex[app].begin(), notifIndex[app].end(),
                               i);
              if (lb != notifIndex[app].end()) {
                ind = lb - notifIndex[app].begin();
                if (index2[app] < (ind)) {
                  index2[app] = ind;
                  ans--;
                }
              }
            }
            notif[i].second = 1;
          }
        }
        tmax = t;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
