#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
template <class T>
class Cmp {
 public:
  bool operator()(const T& lhs, const T& rhs) { return lhs > rhs; }
};
set<int> unread[300010];
vector<pair<int, int>> op;
int main() {
  int n, q, type, x, res = 0, last = 0;
  cin >> n >> q;
  for (int i = 1; i <= q; i++) {
    cin >> type >> x;
    if (type == 1) {
      op.push_back({x, i});
      unread[x].insert(i);
      res++;
    } else if (type == 2) {
      res -= unread[x].size();
      unread[x].clear();
    } else {
      if (x > last) {
        for (int i = last; i < x; i++) {
          auto tmp = op[i];
          if (unread[tmp.first].count(tmp.second) != 0) {
            unread[tmp.first].erase(tmp.second);
            res--;
          }
        }
        last = x;
      }
    }
    cout << res << endl;
  }
  return 0;
}
