#include <bits/stdc++.h>
using namespace std;
int n, m;
int now, num;
int x, y;
vector<int> q[310000];
queue<pair<int, int>> qq;
int last[310000];
int nn;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    if (x == 1) {
      q[y].push_back(++nn);
      num++;
      printf("%d\n", num);
      qq.push(make_pair(nn, y));
    }
    if (x == 2) {
      for (int j = 0; j < q[y].size(); j++) {
        last[y] = q[y][j];
        if (q[y][j] > now) num--;
      }
      q[y].clear();
      printf("%d\n", num);
    }
    if (x == 3) {
      while (!qq.empty() && qq.front().first <= y) {
        if (last[qq.front().second] < qq.front().first) num--;
        qq.pop();
      }
      now = max(now, y);
      printf("%d\n", num);
    }
  }
  return 0;
}
