#include <bits/stdc++.h>
struct app {
  int unread, last_clear;
};
struct e_queue {
  int start, end;
  int apps[300000];
};
struct app apps[300000 + 1];
struct e_queue e;
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  int i, unread = 0;
  e.start = 1;
  for (i = 0; i < q; ++i) {
    int event, val;
    scanf("%d %d", &event, &val);
    if (event == 1) {
      e.apps[++e.end] = val;
      ++apps[val].unread;
      ++unread;
    } else if (event == 2) {
      unread -= apps[val].unread;
      apps[val].unread = 0;
      apps[val].last_clear = e.end;
    } else {
      int j;
      for (j = e.start; j <= val; ++j) {
        if (apps[e.apps[j]].last_clear < j) {
          --apps[e.apps[j]].unread;
          --unread;
        }
      }
      e.start = j;
    }
    printf("%d\n", unread);
  }
}
