#include <bits/stdc++.h>
using namespace std;
queue<int> v[300009];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int c[300009] = {}, k = 0, i, m, n, a[300009], b[300009], sum = 0,
                j = 0;
  int t;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    if (a[i] == 1) {
      c[b[i] - 1]++;
      v[b[i] - 1].push(i);
      sum++;
    } else if (a[i] == 2) {
      sum -= c[b[i] - 1];
      c[b[i] - 1] = 0;
      while (v[b[i] - 1].size()) {
        v[b[i] - 1].pop();
      }
    } else if (a[i] == 3) {
      for (; k < b[i]; j++) {
        if (a[j] == 1) {
          k++;
          if (c[b[j] - 1] > 0 && v[b[j] - 1].front() == j) {
            c[b[j] - 1]--;
            sum--;
            v[b[j] - 1].pop();
          }
        }
      }
    }
    cout << sum << "\n";
  }
  return 0;
}
