#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int cnt = 0, n, ques, mark = 0, ans = 0;
queue<int> q[N];
bool vis[N];
int main() {
  scanf("%d%d", &n, &ques);
  memset(vis, false, sizeof(vis));
  while (ques--) {
    int op, x;
    scanf("%d%d", &op, &x);
    if (op == 1) {
      q[x].push(++cnt);
      ans++;
    } else if (op == 2) {
      while (!q[x].empty()) {
        int u = q[x].front();
        q[x].pop();
        if (u > mark) {
          ans--;
          vis[u] = true;
        }
      }
    } else {
      for (int i = mark + 1; i <= x; i++) {
        if (!vis[i]) ans--;
      }
      mark = max(mark, x);
    }
    printf("%d\n", ans);
  }
  return 0;
}
