#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)5e5 + 10;
int n, Q;
set<pair<int, int> > deleted;
set<pair<int, int> > notif[MAXN];
int main() {
  scanf("%d %d", &n, &Q);
  int totalUnRead = 0;
  set<pair<int, int> > st;
  int idx = 0;
  for (int q = 0; q < Q; q++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int x;
      scanf("%d", &x);
      x--;
      totalUnRead++;
      st.insert(make_pair(idx, x));
      notif[x].insert(make_pair(idx, x));
      idx++;
    } else if (type == 2) {
      int x;
      scanf("%d", &x);
      x--;
      for (auto it : notif[x]) {
        if (deleted.find(it) == deleted.end()) {
          totalUnRead--;
          deleted.insert(it);
        }
      }
      notif[x].clear();
    } else {
      int t;
      scanf("%d", &t);
      vector<pair<int, int> > toDel;
      for (auto it : st) {
        if (it.first < t) {
          toDel.push_back(it);
        } else {
          break;
        }
      }
      for (auto it : toDel) {
        st.erase(it);
        if (deleted.find(it) == deleted.end()) {
          totalUnRead--;
          deleted.insert(it);
        }
      }
    }
    printf("%d\n", totalUnRead);
  }
  return 0;
}
