#include <bits/stdc++.h>
int main() {
  long n, q, type, app, answer = 0, unread[300005] = {0}, read[300005] = {0},
                        query[300005] = {0}, notif = 0, i, j;
  scanf("%ld%ld", &n, &q);
  for (i = 0; i < q; i++) {
    scanf("%ld%ld", &type, &app);
    if (type == 1) {
      query[notif] = app;
      answer++;
      unread[app]++;
      notif++;
    } else if (type == 2) {
      answer -= unread[app];
      read[app] += unread[app];
      unread[app] = 0;
    } else {
      for (j = app - 1; j >= 0; j--) {
        if (!query[j]) break;
        if (read[query[j]] == 0) {
          answer--;
          unread[query[j]]--;
        } else {
          read[query[j]]--;
        }
        query[j] = 0;
      }
    }
    printf("%ld\n", answer);
  }
  return 0;
}
