#include <bits/stdc++.h>
using namespace std;
int aread[300011] = {0}, aunread[300011] = {0};
int main() {
  int n, q;
  cin >> n >> q;
  int read = 0;
  int unread = 0;
  int total = 0;
  queue<int> Q;
  for (int i = 0; i < q; i++) {
    int o, x;
    scanf("%d %d", &o, &x);
    if (o == 1) {
      aunread[x]++;
      unread++;
      Q.push(x);
    }
    if (o == 2) {
      aread[x] += aunread[x];
      unread -= aunread[x];
      aunread[x] = 0;
    }
    if (o == 3) {
      if (x > read) {
        x = x - read;
        while (x > 0 && !Q.empty()) {
          int y = Q.front();
          if (aread[y] > 0) {
            aread[y]--;
          } else if (aunread[y] != 0) {
            aunread[y]--;
            unread--;
          }
          Q.pop();
          read++;
          x--;
        }
      }
    }
    cout << unread << endl;
  }
}
