#include <bits/stdc++.h>
int main() {
  int n, t, v, k(0), p(0), r(0);
  int u[300001] = {};
  int d[300001] = {};
  int q[300001];
  std::scanf("%*d%d", &n);
  while (0 < n--) {
    std::scanf("%d%d", &t, &v);
    switch (t) {
      case 1:
        q[k++] = v, u[v]++, r++;
        break;
      case 2:
        d[v] += u[v], r -= u[v];
        u[v] = 0;
        break;
      case 3:
        while (p < v) {
          if (0 < d[q[p]])
            d[q[p]]--;
          else
            u[q[p]]--, r--;
          ++p;
        }
        break;
    }
    std::printf("%d\n", r);
  }
  return 0;
}
