#include <bits/stdc++.h>
using namespace std;
const int maxN = 300000;
vector<queue<int> > app(maxN + 1);
queue<pair<int, int> > noti;
int unread = 0;
int main() {
  ios::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  int type, x;
  pair<int, int> tmp;
  int maxChecked = 0;
  for (int i = 0; i < Q; i++) {
    cin >> type;
    if (type == 1) {
      cin >> x;
      app[x].push(i);
      noti.push(make_pair(x, i));
      unread++;
    } else if (type == 2) {
      cin >> x;
      while (!app[x].empty()) {
        app[x].pop();
        unread--;
      }
    } else if (type == 3) {
      int check;
      cin >> check;
      int more = check - maxChecked;
      maxChecked = max(maxChecked, check);
      for (int j = 0; j < more; j++) {
        tmp = noti.front();
        noti.pop();
        x = tmp.first;
        int t = tmp.second;
        if (app[x].size() > 0 && app[x].front() == t) {
          app[x].pop();
          unread--;
        }
      }
    }
    cout << unread << "\n";
  }
}
