#include <bits/stdc++.h>
using namespace std;
int t[300005];
int query(int x) {
  int ret = 0;
  while (x > 0) {
    ret += t[x];
    x -= (x & (-x));
  }
  return ret;
}
void add(int x, int val) {
  while (x <= 300005) {
    t[x] += val;
    x += (x & (-x));
  }
}
int arr1[300005];
int arr2[300005];
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  int ty, x, k = 0, j = 0, u, v;
  while (q--) {
    scanf("%d %d", &ty, &x);
    if (ty == 1) {
      add(x, 1);
      arr1[k++] = x;
    } else if (ty == 2) {
      u = query(x) - query(x - 1);
      arr2[x] += u;
      add(x, -u);
    } else {
      for (; j < x; j++) {
        v = arr1[j];
        u = query(v) - query(v - 1);
        if (arr2[v])
          arr2[v]--;
        else {
          if (u >= 1) {
            add(v, -1);
          }
        }
      }
    }
    printf("%d\n", query(n));
  }
}
