#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300000 + 10;
queue<int> app[MAX_N];
queue<pair<int, int> > all;
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  int max_id = 0, ans = 0;
  while (Q--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == 1) {
      ans++;
      app[b].push(++max_id);
      all.push(make_pair(b, max_id));
    } else if (a == 2)
      while (!app[b].empty()) app[b].pop(), ans--;
    else {
      while (!all.empty()) {
        pair<int, int> p = all.front();
        if (p.second <= b)
          all.pop();
        else
          break;
        if (app[p.first].empty() || app[p.first].front() != p.second)
          continue;
        else
          app[p.first].pop(), ans--;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
