#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, q, cnt[N] = {0}, d = 0, pos = 0, a[N], dem = 0;
bool vi[N] = {0};
vector<int> v[N];
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= q; i++) {
    int t, x;
    scanf("%d %d", &t, &x);
    if (t == 1) {
      cnt[x]++;
      d++;
      a[++dem] = x;
      v[x].push_back(dem);
    } else if (t == 2) {
      d -= cnt[x];
      cnt[x] = 0;
      while (v[x].size()) {
        vi[v[x].back()] = 1;
        v[x].pop_back();
      }
    } else {
      for (int j = pos + 1; j <= x; j++) {
        if (!vi[j]) {
          d--;
          cnt[a[j]]--;
          vi[j] = 1;
        }
      }
      pos = max(pos, x);
    }
    printf("%d\n", d);
  }
}
