#include <bits/stdc++.h>
using namespace std;
int bit[300009];
int n;
void update(int in, long long val) {
  while (in <= n) {
    bit[in] += val;
    in += in & (-in);
  }
}
int query(int in) {
  int ret = 0;
  while (in > 0) {
    ret += bit[in];
    in -= (in & (-in));
  }
  return ret;
}
void prin() {
  for (int i = 0; i <= n; i++) {
    cout << i << " " << bit[i] << endl;
  }
}
vector<int> v[300009];
int t;
int no[300009];
int main() {
  int p, q;
  scanf("%d %d", &p, &q);
  n = q;
  fill(bit, bit + q + 5, 0);
  fill(no, no + n + 5, 0);
  int cou = 0;
  t = 1;
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x == 1) {
      cou++;
      v[y].push_back(cou);
      no[cou] = 1;
      update(cou, 1);
    } else if (x == 2) {
      for (int i = 0; i < (int)v[y].size(); i++) {
        int x = v[y][i];
        if (no[x]) {
          update(x, -1);
          no[x] = 0;
        }
      }
      v[y].clear();
    } else {
      for (int i = t; i <= y; i++) {
        if (no[i]) {
          update(i, -1);
          no[i] = 0;
        }
      }
      t = max(t, y + 1);
    }
    int ans = query(cou);
    printf("%d\n", ans);
  }
}
