#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:22222222")
using namespace std;
long long used[300333], kol[300333];
vector<long long> pos[300333];
long long t[388888];
int n, q;
void inc(int x) {
  while (x <= q) {
    t[x]++;
    x += x & -x;
  }
}
long long sum1(int x) {
  long long sum = 0;
  while (x) {
    sum += t[x];
    x -= x & -x;
  }
  return sum;
}
int main() {
  cin >> n >> q;
  long long sum = 0;
  int T = 0;
  for (int i = 1, cnt = 0; i <= q; i++) {
    int type;
    scanf("%d", &type);
    cnt += type == 1;
    if (type <= 2) {
      int x;
      scanf("%d", &x);
      if (type == 1) {
        kol[x]++;
        pos[x].push_back(cnt);
      } else {
        sum -= used[x];
        sum += kol[x];
        used[x] = kol[x];
        for (int j = 0; j < pos[x].size(); j++) inc(pos[x][j]);
        pos[x].clear();
      }
    } else {
      int t;
      scanf("%d", &t);
      T = max(T, t);
    }
    printf("%I64d\n", cnt - (sum + T - sum1(T)));
  }
}
