#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
ll powmod(ll base, ll exp, const ll MOD) {
  ll ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % MOD;
    base = (base * base) % MOD;
    exp >>= 1;
  }
  return ans;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) {
  x = (x + v) % MOD;
  if (x < 0) x += MOD;
}
const int mxN = 3e5 + 9;
using pi = pair<int, int>;
queue<pi> Q;
queue<int> e[mxN];
int mark[mxN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, q;
  cin >> n >> q;
  int ans = 0;
  int idx = 0;
  while (q--) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      ++idx;
      ++ans;
      e[x].push(idx);
      Q.push({idx, x});
    } else if (t == 2) {
      ans -= e[x].size();
      while (e[x].size() > 0) {
        mark[e[x].front()] = 1;
        e[x].pop();
      }
    } else {
      while (!Q.empty() && Q.front().first <= x) {
        int i = Q.front().first;
        int xx = Q.front().second;
        Q.pop();
        if (mark[i] == false) {
          mark[i] = 1;
          e[xx].pop();
          --ans;
        }
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
