#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, q;
int a[N];
int b[N], len = 0;
bool read[N];
int cur = 0;
vector<int> ids[N];
int last = 1;
int main() {
  cin >> n >> q;
  for (int i = 1; i <= q; ++i) {
    int tp, x;
    cin >> tp >> x;
    if (tp == 1) {
      ++cur;
      b[++len] = x;
      ids[x].push_back(len);
    } else if (tp == 2) {
      for (int it = 0; it < ids[x].size(); ++it) {
        int index = ids[x][it];
        if (!read[index]) --cur;
        read[index] = true;
      }
      ids[x].clear();
    } else if (tp == 3) {
      for (int it = last; it <= x; ++it) {
        if (!read[it]) {
          --cur;
          read[it] = true;
        }
      }
    }
    if (tp == 3) last = max(x, last);
    cout << cur << "\n";
  }
  return 0;
}
