#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));
using namespace std;
template <typename T>
struct BIT {
  int n;
  vector<T> bit;
  BIT() : n(0) {}
  BIT(int _n) : n(_n) { bit = vector<T>(n + 1); }
  void add1(int idx, T val) {
    for (int i = idx; i <= n; i += i & -i) bit[i] += val;
  }
  T sum1(int idx) {
    T res = 0;
    for (int i = idx; i > 0; i -= i & -i) res += bit[i];
    return res;
  }
  void add(int idx, T val) { add1(idx + 1, val); }
  T sum(int left, int right) { return sum1(right) - sum1(left); }
  int lower_bound(T x) {
    int res = 0;
    int k = 1;
    while (2 * k <= n) k <<= 1;
    for (; k > 0; k >>= 1) {
      if (res + k <= n and bit[res + k] < x) {
        x -= bit[res + k];
        res += k;
      }
    }
    return res;
  }
};
int main() {
  int n, kkt;
  scanf("%d %d", &n, &kkt);
  BIT<int> bit(n);
  vector<vector<int>> ur(n);
  vector<bool> used(kkt, false);
  vector<int> q(kkt);
  vector<int> v;
  int cur = 0;
  for (int i = 0; i < kkt; i++) {
    int t, x;
    scanf("%d %d", &t, &x);
    x--;
    q[i] = x;
    if (t == 1) {
      bit.add(x, 1);
      ur[x].emplace_back(i);
      v.emplace_back(i);
    }
    if (t == 2) {
      for (auto e : ur[x]) {
        if (!used[e]) {
          used[e] = true;
          bit.add(q[e], -1);
        }
      }
      ur[x].clear();
    }
    if (t == 3) {
      for (; cur <= x; cur++) {
        if (!used[v[cur]]) {
          used[v[cur]] = true;
          bit.add(q[v[cur]], -1);
        }
      }
    }
    printf("%d\n", bit.sum(0, n));
  }
  return 0;
}
