#include <bits/stdc++.h>
using namespace std;
const int inf_int = 2e9;
const long long inf_ll = 2e18;
int Gcd(int p, int q) { return q == 0 ? p : Gcd(q, p % q); }
int Pow(int p, int q) {
  int ans = 1;
  while (q) {
    if (q & 1) ans = ans * p;
    p = p * p;
    q >>= 1;
  }
  return ans;
}
inline int read() {
  int ra, fh;
  char rx;
  rx = getchar(), ra = 0, fh = 1;
  while ((rx < '0' || rx > '9') && rx != '-') rx = getchar();
  if (rx == '-') fh = -1, rx = getchar();
  while (rx >= '0' && rx <= '9') ra *= 10, ra += rx - 48, rx = getchar();
  return ra * fh;
}
int n, q;
vector<int> v[300010];
vector<bool> vis;
int op, x;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  scanf("%d%d", &n, &q);
  int ans = 0, k = 0;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &op, &x);
    if (op == 1) {
      x--;
      v[x].push_back(vis.size());
      vis.push_back(true);
      ans++;
    } else if (op == 2) {
      x--;
      for (int j : v[x]) {
        if (vis[j]) {
          ans--;
          vis[j] = false;
        }
      }
      v[x].clear();
    } else {
      for (int j = k; j < x; j++) {
        if (vis[j]) {
          vis[j] = false;
          ans--;
        }
      }
      k = max(k, x);
    }
    printf("%d\n", ans);
  }
  return 0;
}
