#include <bits/stdc++.h>
using namespace std;
bool mark[300005];
vector<int> v[300005];
int main() {
  int n, q, k = 0, m = 0, c = 1;
  cin >> n >> q;
  while (q--) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      m++;
      k++;
      v[x].push_back(m);
      mark[m] = true;
    } else if (t == 2) {
      for (int i = 0; i < (int)v[x].size(); i++) {
        if (mark[v[x][i]]) {
          k--;
          mark[v[x][i]] = false;
        }
      }
      v[x].clear();
    } else {
      for (int i = c; i <= x; i++) {
        c++;
        if (mark[i]) {
          k--;
          mark[i] = false;
        }
      }
    }
    cout << k << "\n";
  }
  return 0;
}
