#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
deque<int> g[maxn];
deque<pair<int, int> > q;
int main() {
  int n, Q, x, opt, ans = 0, last = 0, first_event = 0;
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d%d", &opt, &x);
    if (opt == 1) {
      first_event++;
      g[x].push_back(first_event);
      q.push_back(make_pair(first_event, x));
      ans++;
    } else if (opt == 2) {
      ans -= g[x].size();
      g[x].clear();
    } else {
      while (!q.empty() && q.front().first <= x) {
        int app = q.front().second;
        while (!g[app].empty() && g[app].front() <= x) {
          ans--;
          g[app].pop_front();
        }
        q.pop_front();
      }
      last = max(last, x);
    }
    printf("%d\n", ans);
  }
  return 0;
}
