#include <bits/stdc++.h>
using namespace std;
int seen[300010], pos_ant[300010], t_ant, resp;
vector<int> pos[300010], pilha;
int main() {
  int n, q, type, t, x;
  while (scanf("%d %d", &n, &q) != EOF) {
    resp = 0;
    t_ant = -1;
    memset(seen, 0, sizeof(seen));
    memset(pos_ant, -1, sizeof(pos_ant));
    for (int i = 0; i < n; i++) pos[i].clear();
    pilha.clear();
    int qnt = 0;
    for (int i = 0; i < q; i++) {
      scanf("%d", &type);
      if (type == 3) {
        scanf("%d", &t);
        t--;
        if (t > t_ant) {
          for (int j = t; j > t_ant; j--) {
            if (seen[j] == 0) {
              resp--;
              seen[j] = 1;
            }
          }
          t_ant = t;
        }
        printf("%d\n", resp);
      } else {
        scanf("%d", &x);
        x--;
        if (type == 1) {
          pilha.push_back(x);
          pos[x].push_back(qnt++);
          resp++;
        } else {
          int tam = pos[x].size();
          for (int j = tam - 1; j > pos_ant[x]; j--) {
            if (seen[pos[x][j]] == 0) {
              resp--;
              seen[pos[x][j]] = 1;
            }
          }
          pos_ant[x] = tam - 1;
        }
        printf("%d\n", resp);
      }
    }
  }
  return 0;
}
