#include <bits/stdc++.h>
using namespace std;
queue<int> que[300010];
queue<pair<int, int>> t;
int v[300010];
int n, q, cnt = 1, ans = 0;
int main() {
  cin >> n >> q;
  for (int i = 1; i <= q; i++) {
    int f, num;
    cin >> f >> num;
    if (f == 1) {
      ans++;
      que[num].push(cnt);
      t.push(make_pair(cnt, num));
      cnt++;
    }
    if (f == 2) {
      while (que[num].size()) {
        v[que[num].front()] = 1;
        que[num].pop();
        ans--;
      }
    }
    if (f == 3) {
      while (t.size() && t.front().first <= num) {
        if (!v[t.front().first]) {
          v[t.front().first] = 1;
          que[t.front().second].pop();
          ans--;
        }
        t.pop();
      }
    }
    cout << ans << endl;
  }
  return 0;
}
