#include <bits/stdc++.h>
using namespace std;
const uint64_t MAXN = 300010;
uint32_t t[4 * MAXN];
int64_t sum(int64_t v, int64_t tl, int64_t tr, int64_t l, int64_t r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  int64_t tm = (tl + tr) / 2;
  return sum(v * 2, tl, tm, l, min(r, tm)) +
         sum(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
void update(int64_t v, int64_t tl, int64_t tr, int64_t pos, int64_t new_val) {
  if (tl == tr)
    t[v] = new_val;
  else {
    int64_t tm = (tl + tr) / 2;
    if (pos <= tm)
      update(v * 2, tl, tm, pos, new_val);
    else
      update(v * 2 + 1, tm + 1, tr, pos, new_val);
    t[v] = t[v * 2] + t[v * 2 + 1];
  }
}
void runOne() {
  uint64_t a, n;
  cin >> a >> n;
  vector<int16_t> types(n);
  vector<uint64_t> args(n);
  for (uint64_t i = 0; i < n; ++i) {
    cin >> types[i] >> args[i];
  }
  vector<vector<uint32_t>> ga(a + 1);
  for (uint64_t i = 1; i <= a; ++i) ga[i].reserve(n / a + 100);
  ostringstream out;
  uint64_t total_added = 0;
  uint64_t total_shown = 0;
  uint64_t out_after_shown = 0;
  for (uint64_t i = 0; i < n; ++i) {
    switch (types[i]) {
      case 1: {
        uint64_t app = args[i];
        ga[app].push_back(total_added);
        total_added += 1;
        break;
      }
      case 2: {
        uint64_t app = args[i];
        auto& ns = ga[app];
        {
          auto e = ns.end();
          auto f = lower_bound(ns.begin(), e, total_shown);
          for (; f != e; ++f) update(1, 0, n - 1, *f, 1);
        }
        ns.clear();
        out_after_shown = sum(1, 0, n - 1, total_shown, total_added);
        break;
      }
      case 3: {
        uint64_t new_total_shown = args[i];
        if (new_total_shown > total_shown) {
          total_shown = new_total_shown;
          out_after_shown = sum(1, 0, n - 1, total_shown, total_added);
        }
        break;
      }
    }
    out << total_added - total_shown - out_after_shown << endl;
  }
  cout << out.str();
}
int main(int, char**) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
  size_t t = 1;
  while (t--) runOne();
  return 0;
}
