#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::map;
using std::max;
using std::min;
using std::pair;
using std::queue;
using std::sort;
using std::string;
using std::vector;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  int data[300001] = {
      0,
  };
  int est[300001] = {
      0,
  };
  int nenado[300001] = {
      0,
  };
  int a, b;
  int last = 1;
  int ploho = 0;
  int answer = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &a, &b);
    if (a == 1) {
      answer++;
      est[b]++;
      cout << answer << '\n';
      data[last++] = b;
    } else if (a == 2) {
      answer -= est[b];
      est[b] = 0;
      nenado[b] = last - 1;
      cout << answer << '\n';
    } else {
      if (b > ploho) {
        for (int j = ploho + 1; j <= b; j++) {
          if (est[data[j]] > 0 && nenado[data[j]] < j) {
            est[data[j]]--;
            answer--;
          }
        }
        ploho = b;
      }
      cout << answer << '\n';
    }
  }
  return 0;
}
