#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  vector<int> apps(n);
  vector<int> lastread(n);
  vector<int> notifs(q);
  int notifcount = 0;
  int unreadcount = 0;
  int nextnotif = 0;
  for (int i = 0; i < q; i++) {
    int type, x;
    scanf("%d %d", &type, &x);
    switch (type) {
      case 1:
        apps[x - 1] += 1;
        notifs[notifcount++] = x - 1;
        unreadcount++;
        break;
      case 2:
        unreadcount -= apps[x - 1];
        apps[x - 1] = 0;
        lastread[x - 1] = notifcount;
        break;
      case 3:
        while (nextnotif < x) {
          if (nextnotif < lastread[notifs[nextnotif]]) {
            nextnotif++;
            continue;
          }
          apps[notifs[nextnotif]]--;
          unreadcount--;
          nextnotif++;
        }
        break;
    }
    printf("%d\n", unreadcount);
  }
  return 0;
}
