#include <bits/stdc++.h>
using namespace std;
void smain();
int main() {
  ios_base::sync_with_stdio(0);
  smain();
  return 0;
}
int n, q;
int a[300002];
vector<pair<int, int> > b[300002];
void smain() {
  for (; scanf("%d%d", &n, &q) != EOF;) {
    for (int i = 0; i < n + 1; i++) b[i].clear();
    set<pair<int, int> > s;
    int m = 0;
    for (int i = 0; i < q; i++) {
      int tp;
      scanf("%d", &tp);
      if (tp == 1) {
        scanf("%d", a + m);
        s.emplace(m, a[m]);
        b[a[m]].emplace_back(m, a[m]);
        m += 1;
      } else if (tp == 2) {
        int x;
        scanf("%d", &x);
        for (auto it : b[x]) {
          s.erase(it);
        }
        b[x].clear();
      } else {
        int t;
        scanf("%d", &t);
        for (; !s.empty() && s.begin()->first < t;) {
          s.erase(s.begin());
        }
      }
      printf("%d\n", (int)s.size());
    }
  }
}
