#include <bits/stdc++.h>
using namespace std;
const int MAX = 333000;
vector<int> notices[MAX];
queue<int> all;
bool del[MAX];
int next_id = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  memset(del, false, sizeof(del));
  int unread = 0;
  for (int qq = 0, ty; qq < Q; ++qq) {
    cin >> ty;
    if (ty == 1) {
      int x;
      cin >> x;
      all.push(next_id);
      notices[x].push_back(next_id++);
      ++unread;
    } else if (ty == 2) {
      int x;
      cin >> x;
      for (int id : notices[x]) {
        if (!del[id]) {
          del[id] = true;
          --unread;
        }
      }
      notices[x].clear();
    } else {
      int t;
      cin >> t;
      while (!all.empty() && all.front() < t) {
        const int id = all.front();
        all.pop();
        if (!del[id]) {
          del[id] = true;
          --unread;
        }
      }
    }
    cout << unread << '\n';
  }
  return 0;
}
