#include <bits/stdc++.h>
using namespace std;
int book[1008611];
int sum, pre[1008611], tail[1008611];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int i, j, x, y, k = 0, t = 0, ans = 0, lt = 0;
  fill(tail, tail + 1008611, -1);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if (x == 1) {
      ans++;
      pre[++k] = tail[y];
      tail[y] = k;
    } else if (x == 2) {
      int tmp = tail[y];
      while (tmp != -1 && book[tmp] == 0) {
        if (book[tmp] == 0) {
          book[tmp] = 1;
          tmp = pre[tmp];
          ans--;
        }
      }
    } else if (x == 3) {
      for (j = lt + 1; j <= y; j++) {
        if (!book[j]) {
          book[j] = 1;
          ans--;
        }
      }
      lt = max(lt, y);
    }
    printf("%d\n", ans);
  }
  return 0;
}
