#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 123;
const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
int n, q, start, t[4 * N];
vector<int> p[N];
void update(int v, int tl, int tr, int pos, int x) {
  if (tl == tr)
    t[v] = x;
  else {
    int mid = (tl + tr) / 2;
    if (pos <= mid)
      update(2 * v, tl, mid, pos, x);
    else
      update(2 * v + 1, mid + 1, tr, pos, x);
    t[v] = t[2 * v] + t[2 * v + 1];
  }
}
int get(int v, int tl, int tr, int l, int r) {
  if (tl > r || tr < l) return 0;
  if (tl >= l && tr <= r) return t[v];
  int mid = (tl + tr) / 2;
  return get(2 * v, tl, mid, l, r) + get(2 * v + 1, mid + 1, tr, l, r);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  int d = 1;
  for (int i = 1, v, x; i <= q; i++) {
    cin >> v >> x;
    if (v == 1) {
      p[x].push_back(d);
      update(1, 1, q, d, 1);
      d++;
    } else if (v == 2) {
      while (!p[x].empty()) {
        int cur = p[x].back();
        update(1, 1, q, cur, 0);
        p[x].pop_back();
      }
    } else {
      start = max(start, x + 1);
    }
    cout << get(1, 1, q, start, q) << "\n";
  }
}
