#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 100;
int n, q, ans, c, a, b, t, d, ar[MAX];
deque<int> v[MAX];
bool place[MAX];
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &a, &b);
    if (a == 1) {
      ar[c] = b;
      v[b].push_back(c++);
      ans++;
    } else if (a == 2)
      while (!v[b].empty()) {
        place[v[b][0]] = 1;
        v[b].pop_front();
        ans--;
      }
    else {
      for (int j = t; j < b; j++)
        if (!place[j]) {
          ans--;
          v[ar[j]].pop_front();
          place[j] = 1;
        }
      t = max(t, b);
    }
    printf("%d\n", ans);
  }
}
