#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double PI = acos(-1);
const long long MOD = 1000000007;
const long long FMOD = 998244353;
const long double eps = 1e-9;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
const long long N = 300006;
map<long long, long long> mp1;
queue<long long> v[N];
queue<pair<long long, long long> > q;
signed main() {
  long long n, q1;
  cin >> n >> q1;
  long long cnt = 1, ans = 0;
  while (q1--) {
    long long type, x;
    cin >> type >> x;
    if (type == 1) {
      v[x].push(cnt);
      q.push(make_pair(cnt, x));
      cnt++;
      ans++;
    } else if (type == 2) {
      ans -= v[x].size();
      while (!v[x].empty()) {
        mp1[v[x].front()] = 1;
        v[x].pop();
      }
    } else {
      while (!q.empty() && q.front().first <= x) {
        if (!mp1[q.front().first]) {
          mp1[q.front().first] = 1;
          ans--;
          v[q.front().second].pop();
        }
        q.pop();
      }
    }
    cout << ans << endl;
  }
}
