#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
struct node {
  int time, pos;
};
queue<node> que;
queue<int> Q[N];
bool vis[N];
int main() {
  int n, q, order, num;
  scanf("%d%d", &n, &q);
  memset(vis, false, sizeof(vis));
  int ans = 0, ant = 1;
  while (q--) {
    scanf("%d%d", &order, &num);
    if (order == 1) {
      node temp;
      temp.time = ant;
      temp.pos = num;
      que.push(temp);
      Q[num].push(ant);
      ans++;
      ant++;
    } else if (order == 2) {
      while (!Q[num].empty()) {
        int u = Q[num].front();
        Q[num].pop();
        vis[u] = true;
        ans--;
      }
    } else {
      while (!que.empty() && que.front().time <= num) {
        node u = que.front();
        if (!vis[u.time]) {
          Q[u.pos].pop();
          vis[u.time] = true;
          ans--;
        }
        que.pop();
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
