#include <bits/stdc++.h>
using namespace std;
const int MX = 300100;
const int MOD = int(360);
const int oo = 1e8;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  queue<int> v;
  vector<queue<int> > w(MX);
  vector<bool> rd(MX);
  int tt = 0, t, x, ans = 0;
  for (int id = 1; q--;) {
    cin >> t >> x;
    if (t == 1) {
      v.push(id);
      w[x].push(id);
      id++;
      ans++;
    } else if (t == 2) {
      while (!w[x].empty()) {
        if (!rd[w[x].front()]) {
          rd[w[x].front()] = true;
          ans--;
        }
        w[x].pop();
      }
    } else {
      tt = max(tt, x);
      while (!v.empty() && v.front() <= tt) {
        if (!rd[v.front()]) {
          rd[v.front()] = true;
          ans--;
        }
        v.pop();
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
