#include <bits/stdc++.h>
using namespace std;
int nxt[300002];
bool state_f[300002];
bool state_h[300002];
int head[300002];
bool read[300002];
int main() {
  int n, q;
  while (scanf("%d %d", &n, &q) != EOF) {
    memset(read, 0, sizeof(read));
    memset(state_h, 0, sizeof(state_h));
    memset(head, -1, sizeof(head));
    memset(state_f, 0, sizeof(state_f));
    int len = 0;
    int sum = 0;
    int last = 1;
    while (q--) {
      int option, id;
      scanf("%d %d", &option, &id);
      if (option == 1) {
        len++;
        nxt[len] = head[id];
        head[id] = len;
        sum++;
      } else if (option == 2) {
        int p = head[id];
        while (p != -1) {
          if (state_h[p])
            break;
          else
            state_h[p] = true;
          if (!read[p]) sum--;
          read[p] = true;
          p = nxt[p];
        }
      } else if (option == 3) {
        int p;
        for (p = last; p <= id; p++) {
          if (!read[p]) sum--;
          state_f[p] = true;
          read[p] = true;
        }
        last = p;
      }
      printf("%d\n", sum);
    }
  }
  return 0;
}
