#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<deque<int>> app(n + 1);
  deque<pair<int, int>> notification;
  for (int i = 0, unread = 0, total = 0, type, k; i < q; i++) {
    cin >> type >> k;
    if (type == 1) {
      unread++;
      total++;
      app[k].push_back(total);
      notification.push_back({total, k});
    } else if (type == 2) {
      unread -= app[k].size();
      app[k].clear();
    } else {
      while (!notification.empty() && notification.front().first <= k) {
        int x = notification.front().second;
        notification.pop_front();
        if (!app[x].empty() && app[x].front() <= k) {
          app[x].pop_front();
          unread--;
        }
      }
    }
    cout << unread << '\n';
  }
  return 0;
}
