#include <bits/stdc++.h>
using namespace std;
int n, m, k, x, ans, cnt, mx;
queue<int> q[300005];
bool vis[300005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &k, &x);
    if (k == 1) {
      ++ans;
      ++cnt;
      q[x].push(cnt);
    } else if (k == 2) {
      while (!q[x].empty()) {
        int a = q[x].front();
        q[x].pop();
        if (!vis[a]) {
          ans--;
          vis[a] = 1;
        }
      }
    } else {
      if (x > mx) {
        for (int j = mx + 1; j <= x; j++) {
          if (!vis[j]) {
            ans--;
            vis[j] = 1;
          }
        }
        mx = x;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
