#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 10;
int read_msg[N];
queue<int> apps[N];
void solve() {
  int n, q;
  cin >> n >> q;
  int idx = 0, cnt = 0;
  int tot = 0;
  int done = 0;
  for (int i = 0; i < q; ++i) {
    int type, x;
    cin >> type >> x;
    x--;
    if (type == 1) {
      apps[x].push(cnt++);
      tot++;
    } else if (type == 2) {
      while (apps[x].size()) {
        int cidx = apps[x].front();
        apps[x].pop();
        if (!read_msg[cidx]) {
          read_msg[cidx] = 1;
          done++;
        }
      }
    } else {
      while (idx <= x) {
        if (!read_msg[idx]) {
          read_msg[idx] = 1;
          done++;
        }
        idx++;
      }
    }
    cout << tot - done << endl;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  solve();
  return 0;
}
