#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int MAXM = 300010;
const int INF = 0x7fffffff;
const long long MOD = 1e9 + 7;
const double eps = 1e-5;
const double pi = acos(-1.0);
int num[300010], r[300010], last[300010];
vector<int> v;
int main() {
  memset(num, 0, sizeof num);
  memset(last, 0, sizeof last);
  memset(r, 0, sizeof r);
  int n, q;
  scanf("%d%d", &n, &q);
  int s = 0;
  int ds = 0;
  int lx = 1;
  for (int i = 1; i <= q; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == 1) {
      s++;
      v.push_back(y);
      num[y]++;
    }
    if (x == 2) {
      r[y] = s;
      ds += num[y] - last[y];
      last[y] = num[y];
    }
    if (x == 3) {
      while (lx <= y) {
        if (r[v[lx - 1]] < lx) {
          last[v[lx - 1]]++;
          ds++;
        }
        lx++;
      }
    }
    printf("%d\n", s - ds);
  }
}
