#include <bits/stdc++.h>
using namespace std;
const int Max_N(300050);
int N, Q;
int type, x;
vector<int> All, que[Max_N];
int last, Ans;
bool have[Max_N];
int main() {
  scanf("%d%d", &N, &Q);
  All.push_back(0);
  for (int i = 1; i <= N; ++i) que[i].push_back(0);
  for (int i = 1; i <= Q; ++i) {
    scanf("%d%d", &type, &x);
    if (type == 1) All.push_back(i), que[x].push_back(i), ++Ans;
    if (type == 2)
      for (int j = que[x].size() - 1; j >= 1; --j)
        if (!have[que[x][j]])
          --Ans, have[que[x][j]] = true;
        else
          break;
    if (type == 3)
      if (x > last) {
        for (int j = last + 1; j <= x; ++j) {
          if (!have[All[j]]) --Ans;
          have[All[j]] = true;
        }
        last = x;
      }
    printf("%d\n", Ans);
  }
  return 0;
}
