#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1000000009;
const int N = 3e5 + 10;
int n, q;
int opr, x, cnt;
int ans, cur;
int a[N], vis[N];
vector<int> t[N];
int main() {
  cin >> n >> q;
  for (int i = (1); i <= (q); i++) {
    cin >> opr >> x;
    if (opr == 1) {
      ans++;
      a[++cnt] = x;
      t[x].push_back(cnt);
    } else if (opr == 2) {
      for (int i = 0; i < t[x].size(); i++) {
        if (vis[t[x][i]]) continue;
        vis[t[x][i]] = 1;
        ans--;
      }
      t[x].clear();
    } else if (opr == 3) {
      if (x > cur) {
        for (int j = (cur + 1); j <= (x); j++) {
          if (!vis[j]) {
            vis[j] = 1;
            ans--;
          }
        }
        cur = x;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
