#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(move(x));
  return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
int N, Q;
int nloc[300013];
vector<int> view[300013];
int viewa[300013];
int ans = 0;
int ith[300013];
int idx = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  int p = 0;
  for (int q = 0; q < Q; q++) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      ith[idx++] = q;
      nloc[q] = x;
      view[x].push_back(q);
      ans++;
      viewa[x]++;
    } else if (t == 2) {
      for (int y : view[x]) {
        nloc[y] = 0;
      }
      view[x].clear();
      ans -= viewa[x];
      viewa[x] = 0;
    } else {
      for (; p < x; p++) {
        if (nloc[ith[p]]) {
          viewa[nloc[ith[p]]]--;
          ans--;
        }
      }
    }
    cout << ans << '\n';
  }
  cout.flush();
  return 0;
}
