#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  int unr = 0;
  queue<pair<int, int> > noti;
  int q_num = 0;
  vector<queue<int> > v(n + 1);
  while (q--) {
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      unr++;
      q_num++;
      v[x].push(q_num);
      noti.push({q_num, x});
    } else if (t == 2) {
      unr -= v[x].size();
      v[x] = {};
    } else {
      while (!noti.empty() && noti.front().first <= x) {
        int id = noti.front().second;
        int val = noti.front().first;
        noti.pop();
        if (!v[id].empty() && v[id].front() == val) {
          v[id].pop();
          unr--;
        }
      }
    }
    cout << unr << "\n";
  }
}
