#include <bits/stdc++.h>
using namespace std;
int n, q, num[300010], sum, l[300010], pos, rpos;
bool vis[300010];
queue<int> qu[300010];
int main() {
  scanf("%d%d", &n, &q);
  int op, x;
  while (q--) {
    scanf("%d%d", &op, &x);
    if (op == 1) {
      num[x]++;
      sum++;
      qu[x].push(pos);
      l[pos++] = x;
    } else if (op == 2) {
      while (!qu[x].empty()) {
        int temp = qu[x].front();
        qu[x].pop();
        vis[temp] = true;
      }
      sum -= num[x];
      num[x] = 0;
    } else {
      for (int i = rpos; i < x; i++) {
        if (vis[i]) continue;
        qu[l[i]].pop();
        num[l[i]]--;
        sum--;
        vis[i] = true;
      }
      rpos = max(rpos, x);
    }
    printf("%d\n", sum);
  }
  return 0;
}
