#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const long long MAX = 1e9 + 7;
const long long mod = 1e9 + 7;
const long long maxn = 3e5 + 5;
int n, qq;
int type, sum;
int s[maxn], vis[maxn];
struct node {
  int x, y;
} a[maxn];
queue<int> q[maxn];
int main() {
  scanf("%d%d", &n, &qq);
  long long ans = 0;
  int k = 0, kk = 0;
  for (int i = 1; i <= qq; i++) {
    scanf("%d%d", &type, &sum);
    if (type == 1) {
      q[sum].push(k);
      vis[k] = 1;
      a[k].x = i;
      a[k++].y = sum;
      ans++;
    }
    if (type == 2) {
      while (!q[sum].empty()) {
        int y = q[sum].front();
        if (vis[y]) ans--, vis[y] = 0;
        q[sum].pop();
      }
    }
    if (type == 3) {
      for (; kk < min(sum, k); kk++) {
        if (vis[kk]) ans--, vis[kk] = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
