#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long mod2 = 998244353;
const long double pi = 3.1415926535;
void solve() {
  long long n, q;
  cin >> n >> q;
  vector<bool> mark;
  long long M[300005] = {0};
  map<long long, queue<long long>> Fr;
  queue<pair<long long, long long>> Q;
  long long type, hari, sum = 0, cnt = 0;
  while (q--) {
    cin >> type >> hari;
    if (type == 1) {
      sum++;
      M[hari]++;
      Fr[hari].push(cnt);
      mark.push_back(0);
      Q.push({hari, cnt++});
    } else if (type == 2) {
      sum -= M[hari];
      while (!Fr[hari].empty()) {
        mark[Fr[hari].front()] = 1;
        Fr[hari].pop();
      }
      M[hari] = 0;
    } else {
      while (!Q.empty() && Q.front().second < hari) {
        if (!mark[Q.front().second]) {
          mark[Q.front().second] = 1, sum--;
          if (Fr[Q.front().first].front() == Q.front().second) {
            M[Q.front().first]--;
            Fr[Q.front().first].pop();
          }
        }
        Q.pop();
      }
    }
    cout << sum << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
