#include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e9 + 10;
const long long int INFLL = (long long int)1e18 + 10;
const long double EPS = 1e-12;
const long long int MOD = 1e9 + 7;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
template <class T>
inline T sq(T a) {
  return a * a;
}
long long int in() {
  long long int x;
  scanf("%lld", &x);
  return x;
}
char yuyushiki[1000010];
string stin() {
  scanf("%s", yuyushiki);
  return yuyushiki;
}
int n, q;
queue<pair<int, int> > que;
queue<int> app[300010];
int it = 0;
int ans = 0;
int main() {
  n = in();
  q = in();
  for (long long int i = (0); i < (long long int)(q); i++) {
    int t = in();
    if (t == 1) {
      int x = in() - 1;
      ans++;
      que.push(pair<int, int>(it, x));
      app[x].push(it);
      it++;
    } else if (t == 2) {
      int x = in() - 1;
      while (!app[x].empty()) {
        app[x].pop();
        ans--;
      }
    } else if (t == 3) {
      int t = in();
      while (!que.empty() && que.front().first < t) {
        pair<int, int> x = que.front();
        que.pop();
        if (!app[x.second].empty() && app[x.second].front() == x.first) {
          app[x.second].pop();
          ans--;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
