#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int head[N];
bool vis[N];
int n, cnt;
struct Edge {
  int next, v;
};
Edge edge[N];
void add(int u, int v) {
  edge[cnt].next = head[u];
  edge[cnt].v = v;
  head[u] = cnt++;
}
int main() {
  int q, a, b, number = 0, use = 0, prelen = 0, flag, cnt = 0;
  memset(head, -1, sizeof(head));
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &a, &b);
    if (a == 1) {
      number++;
      add(b, number);
      printf("%d\n", number - use);
      continue;
    }
    if (a == 2) {
      for (int j = head[b]; j != -1; j = edge[j].next) {
        flag = edge[j].v;
        if (!vis[flag]) {
          use++;
          vis[flag] = true;
        }
      }
      head[b] = -1;
      printf("%d\n", number - use);
      continue;
    }
    for (int j = prelen + 1; j <= b; j++) {
      if (!vis[j]) {
        use++;
        vis[j] = true;
      }
    }
    prelen = max(prelen, b);
    printf("%d\n", number - use);
  }
  return 0;
}
