#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000;
int n, q, maxi;
int t[maxn + 1];
vector<int> v[maxn + 1];
int getBIT(int x) {
  int res = 0;
  for (; x > 0; x &= (x - 1)) res += t[x];
  return res;
}
void updateBIT(int x, int v) {
  for (; x <= q; x += x & (-x)) t[x] += v;
}
int tong(int x, int y) { return getBIT(y) - getBIT(x - 1); }
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> q;
  int ans = 0, maxi = 0, t = 0;
  for (int i = 1; i <= q; i++) {
    int op, x;
    cin >> op >> x;
    if (op == 1) {
      t++;
      v[x].push_back(t);
      ans++;
    } else if (op == 2) {
      for (auto it = v[x].begin(); it != v[x].end(); it++)
        if (*it > maxi) {
          updateBIT(*it, 1);
          ans--;
        }
      v[x].clear();
    } else if (op == 3 and x > maxi) {
      ans -= ((x - maxi) - tong(maxi + 1, x));
      maxi = max(maxi, x);
    }
    cout << ans << '\n';
  }
  return 0;
}
