#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
queue<int> q[300010];
queue<pair<int, int> > Q;
int mark[300010];
int main() {
  int ans = 0, n, m, opt, x, c = 0;
  cin >> n >> m;
  for (int i = (1); i <= (m); i++) {
    scanf("%d", &opt);
    scanf("%d", &x);
    if (opt == 1) {
      ans++;
      c++;
      q[x].push(c);
      Q.push(make_pair(c, x));
    } else if (opt == 2) {
      ans -= (int)(q[x].size());
      while (!q[x].empty()) {
        mark[q[x].front()] = 1;
        q[x].pop();
      }
    } else if (opt == 3) {
      while (!Q.empty() and Q.front().first <= x) {
        pair<int, int> tmp = Q.front();
        Q.pop();
        if (mark[tmp.first] != 1) {
          mark[tmp.first] = 1;
          q[tmp.second].pop();
          ans--;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
