#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, q, type, x, cnt = 0;
  scanf("%d%d", &n, &q);
  int a[n + 1];
  int noteRead[n + 1];
  int count[n + 1];
  memset(count, 0, sizeof count);
  memset(a, 0, sizeof a);
  memset(noteRead, 0, sizeof noteRead);
  vector<int> events;
  j = 0;
  while (q--) {
    scanf("%d%d", &type, &x);
    if (type == 1) {
      a[x]++;
      events.push_back(x);
      cnt++;
    } else if (type == 2) {
      cnt -= (a[x] - noteRead[x]);
      noteRead[x] = a[x];
    } else if (type == 3) {
      for (; j < x; j++) {
        count[events[j]]++;
        if (count[events[j]] > noteRead[events[j]]) {
          cnt--;
          noteRead[events[j]]++;
        }
      }
    }
    printf("%d\n", cnt);
  }
}
