#include <bits/stdc++.h>
using namespace std;
int n, q;
vector<int> nots;
int rct, apprct[300000], apprct2[300000];
vector<int> haveread[300000];
int unread;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  for (int c = 0; c < q; c++) {
    int i, j;
    cin >> i >> j;
    if (i < 3) {
      j--;
      if (i == 1) {
        unread++;
        haveread[j].push_back(0);
        nots.push_back(j);
      } else {
        for (; apprct[j] < haveread[j].size(); apprct[j]++) {
          int k = apprct[j];
          if (!haveread[j][k]) {
            haveread[j][k] = 1;
            unread--;
          }
        }
      }
    } else {
      for (; rct < j; rct++) {
        int k = nots[rct];
        int l = apprct2[k]++;
        if (!haveread[k][l]) {
          haveread[k][l] = 1;
          unread--;
        }
      }
    }
    cout << unread << '\n';
  }
}
