#include <bits/stdc++.h>
using namespace std;
inline double Time() { return (clock() * 1.0) / CLOCKS_PER_SEC; }
const int N = 300500, inf = 1e9 * 2, MOD = 1e9 + 7;
char CH[N];
const long long INF = 1e18;
const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};
bool done[N];
vector<int> pos[N];
int main() {
  unsigned int FOR;
  asm("rdtsc" : "=A"(FOR));
  srand(FOR);
  int n, qq;
  cin >> n >> qq;
  vector<int> q;
  int all = 0, did = 0;
  for (int i = 1; i <= qq; i++) {
    int ty, x;
    scanf("%d %d", &ty, &x);
    if (ty == 1) {
      all++;
      pos[x].push_back((int((q).size())));
      q.push_back(x);
    }
    if (ty == 2) {
      for (auto i : pos[x]) {
        if (!done[i]) all--;
        done[i] = 1;
      }
      pos[x].clear();
    }
    if (ty == 3) {
      x = max(0, x - did);
      while (x > 0) {
        x--;
        if (done[did++]) continue;
        done[did - 1] = 1;
        all--;
      }
    }
    printf("%d\n", all);
  }
  return 0;
}
