#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, ans = 0, a, b, c = 0, t;
  map<int, int> unread, read, check;
  queue<int> arr;
  scanf("%d %d", &n, &q);
  while (q--) {
    scanf("%d %d", &a, &b);
    if (a == 1) {
      ans++;
      unread[b]++;
      arr.push(b);
    } else if (a == 2) {
      ans -= unread[b] - read[b];
      read[b] = unread[b];
    } else {
      t = b - c;
      while (!arr.empty() and t > 0) {
        t--;
        c++;
        a = arr.front();
        arr.pop();
        check[a]++;
        if (check[a] > read[a]) {
          ans -= check[a] - read[a];
          read[a] = check[a];
        }
      }
    }
    printf("%d\n", ans);
  }
}
