#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
inline long long inL() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int N = 3e5 + 9;
vector<long long> vec[N], query;
long long cum[N], app[N];
bool visited[N];
int main() {
  int n = in(), q = in();
  long long unr = 0, dunr = 0, rem = 0;
  for (int i = 0; i < q; i++) {
    int t = in(), x = in();
    if (t == 1) {
      query.push_back(x);
      unr++;
      app[x]++;
      vec[x].push_back(unr);
    } else if (t == 2) {
      for (long long j = cum[x]; j < app[x]; j++)
        if (not visited[vec[x][j]]) {
          rem++;
          visited[vec[x][j]] = true;
        }
      cum[x] = app[x];
    } else {
      for (long long j = dunr + 1; j <= x; j++)
        if (not visited[j]) {
          rem++;
          visited[j] = true;
          cum[query[j - 1]]++;
        }
      if (dunr < x) dunr = x;
    }
    cout << unr - rem << endl;
  }
  return 0;
}
