#include <bits/stdc++.h>
using namespace std;
int n, q;
list<int> position[400000];
bool readed[400000];
int main() {
  while (cin >> n >> q) {
    list<pair<int, int> > lst;
    memset(readed, 0, sizeof(readed));
    int cnt = 0, ans = 0;
    while (q--) {
      int typ, v;
      scanf("%d %d", &typ, &v);
      if (typ == 1) {
        lst.push_back({++cnt, v});
        position[v].push_back(cnt);
        ans++;
      } else if (typ == 2) {
        for (auto it = position[v].begin(); it != position[v].end();) {
          if (readed[*it] == 0) {
            readed[*it] = 1;
            ans--;
          }
          it = position[v].erase(it);
        }
      } else {
        for (auto it = lst.begin(); it != lst.end();)
          if ((*it).first <= v) {
            if (readed[(*it).first] == 0) {
              ans--;
              readed[(*it).first] = 1;
            }
            it = lst.erase(it);
          } else
            break;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
