#include <bits/stdc++.h>
using namespace std;
struct item {
  int l, r;
  int id;
  int v;
};
const int MAX = 3e5 + 10;
int n, q;
item a[MAX];
list<int> app[MAX];
int first, last, unread;
void push(int x) {
  unread++;
  last++;
  a[last].id = last;
  a[last].v = x;
  a[last].r = last + 1;
  a[last + 1].l = last;
  app[x].push_back(last);
}
void pop(int p) {
  unread--;
  a[a[p].l].r = a[p].r;
  a[a[p].r].l = a[p].l;
  app[a[p].v].pop_front();
  if (first == a[p].id) first = a[p].r;
}
int main() {
  scanf("%d%d", &n, &q);
  first = 1;
  last = 0;
  unread = 0;
  a[0].r = 1;
  for (int i = 1; i <= q; i++) {
    int type, x;
    scanf("%d", &type);
    if (type == 1) {
      scanf("%d", &x);
      push(x);
    } else if (type == 2) {
      scanf("%d", &x);
      while (!app[x].empty()) pop(app[x].front());
    } else {
      scanf("%d", &x);
      for (int j = first; j <= x; j = a[j].r) pop(j);
    }
    printf("%d\n", unread);
  }
}
