#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5 + 5;
int qu[mx], num[mx], lst[mx];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q, ct = 0, ret = 0, l = 0;
  cin >> n >> q;
  while (q--) {
    int type, x;
    cin >> type >> x;
    if (type == 1)
      qu[++ct] = x, num[x]++, ret++;
    else if (type == 2)
      ret -= num[x], num[x] = 0, lst[x] = ct;
    else {
      while (l < x) {
        l++;
        if (lst[qu[l]] >= l) continue;
        lst[qu[l]] = l, num[qu[l]]--;
        ret--;
      }
    }
    cout << ret << endl;
  }
  return 0;
}
