#include <bits/stdc++.h>
using namespace std;
int n, tt[300005], Q, res[300005], sum[300005];
struct node {
  int x, t;
  node(int a, int b) {
    x = a;
    t = b;
  }
};
queue<node> q;
int main() {
  cin >> n >> Q;
  int ans = 0, cnt = 0;
  memset(tt, 0, sizeof(tt));
  for (int i = 1; i <= Q; i++) {
    int op, a;
    cin >> op >> a;
    if (op == 1) {
      cnt++;
      q.push(node(a, cnt));
      res[a]++;
      ans++;
      sum[i] = ans;
    } else if (op == 2) {
      ans -= res[a];
      res[a] = 0;
      tt[a] = cnt;
      sum[i] = ans;
    } else {
      int k = 0;
      while (!q.empty()) {
        node u = q.front();
        if (u.t > a) break;
        q.pop();
        if (u.t > tt[u.x]) {
          ans--;
          res[u.x]--;
        }
      }
      sum[i] = ans;
    }
  }
  for (int i = 1; i <= Q; i++) cout << sum[i] << endl;
  return 0;
}
