#include <bits/stdc++.h>
using namespace std;
int n, q, c[300005], a[4 * 300005], ans = 0, cnt;
vector<int> H[300005];
void build(int t, int l, int r) {
  int mid = (l + r) >> 1;
  if (l == r) return;
  a[t] = (1 << 30);
  build((t << 1), l, mid);
  build(((t << 1) | 1), mid + 1, r);
}
void modify(int t, int l, int r, int x) {
  int mid = (l + r) >> 1;
  if (l == r) {
    if (c[l] == H[l].size())
      a[t] = (1 << 30);
    else
      a[t] = H[l][c[l]];
    return;
  }
  if (x <= mid)
    modify((t << 1), l, mid, x);
  else
    modify(((t << 1) | 1), mid + 1, r, x);
  a[t] = min(a[(t << 1)], a[((t << 1) | 1)]);
}
void query(int t, int l, int r, int x) {
  int mid = (l + r) >> 1;
  if (l == r) {
    while (c[l] < H[l].size() && H[l][c[l]] <= x) ans--, c[l]++;
    if (c[l] == H[l].size())
      a[t] = (1 << 30);
    else
      a[t] = H[l][c[l]];
    return;
  }
  if (a[(t << 1)] <= x) query((t << 1), l, mid, x);
  if (a[((t << 1) | 1)] <= x) query(((t << 1) | 1), mid + 1, r, x);
  a[t] = min(a[(t << 1)], a[((t << 1) | 1)]);
}
int main() {
  int i, op, x;
  scanf("%d %d", &n, &q);
  build(1, 1, n);
  for (i = 1; i <= q; i++) {
    scanf("%d %d", &op, &x);
    if (op == 1) {
      H[x].push_back(++cnt);
      modify(1, 1, n, x), ans++;
    }
    if (op == 2) {
      while (c[x] < H[x].size()) ans--, c[x]++;
      modify(1, 1, n, x);
    }
    if (op == 3) query(1, 1, n, x);
    printf("%d\n", ans);
  }
  return 0;
}
