#include <bits/stdc++.h>
using namespace std;
void solve();
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
void solve() {
  long long int i, j;
  long long int n, q;
  cin >> n >> q;
  queue<pair<long long int, long long int>> notifications;
  vector<queue<long long int>> app(n + 1);
  vector<bool> mark(q + 1, false);
  long long int ans = 0, t = 0;
  for (i = 0; i < q; i++) {
    long long int u, v;
    cin >> u >> v;
    if (u == 1) {
      notifications.push({t, v});
      app[v].push(t);
      ans++;
      t++;
    } else if (u == 2) {
      while (!app[v].empty()) {
        long long int time = app[v].front();
        app[v].pop();
        if (!mark[time]) {
          mark[time] = 1;
          ans--;
        }
      }
    } else {
      while (!notifications.empty()) {
        long long int time = notifications.front().first;
        if (time >= v) {
          break;
        }
        notifications.pop();
        if (!mark[time]) {
          mark[time] = 1;
          ans--;
        }
      }
    }
    cout << ans << "\n";
  }
}
