#include <bits/stdc++.h>
using namespace std;
template <typename tn>
void read(tn& a) {
  tn x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  a = x * f;
}
template <typename tn>
void cmax(tn& a, tn b) {
  if (b > a) a = b;
}
template <typename tn>
void cmin(tn& a, tn b) {
  if (b < a) a = b;
}
template <typename tn>
tn ABS(tn a) {
  return a < 0 ? -a : a;
}
template <typename tn>
tn SQR(tn a) {
  return a * a;
}
const int N = 330000;
queue<int> q[N];
int c[N];
int n;
int m;
int lowbit(int x) { return x & (-x); }
int query(int x) {
  int ret = 0;
  while (x > 0) {
    ret += c[x];
    x -= lowbit(x);
  }
  return ret;
}
void insert(int x, int v) {
  while (x <= m) {
    c[x] += v;
    x += lowbit(x);
  }
}
int main() {
  read(n);
  read(m);
  int tot = 0, mx = 0, ans = 0;
  for (int i = (1); i <= (m); i++) {
    int o;
    read(o);
    if (o == 1) {
      int x;
      read(x);
      tot++;
      insert(tot, 1);
      q[x].push(tot);
      ans++;
      printf("%d\n", ans);
    } else if (o == 2) {
      int x;
      read(x);
      while (!q[x].empty()) {
        int t = q[x].front();
        q[x].pop();
        if (t <= mx) continue;
        ans--;
        insert(t, -1);
      }
      printf("%d\n", ans);
    } else {
      int k;
      read(k);
      if (k <= mx) {
        printf("%d\n", ans);
        continue;
      }
      k = min(k, tot);
      int t1 = query(k), t2 = query(mx);
      ans -= t1 - t2;
      printf("%d\n", ans);
      mx = k;
    }
  }
  return 0;
}
