#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
const int MAX_NOTIF_NR = 3e5;
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  vector<vector<int>> app(n + 1);
  bitset<MAX_NOTIF_NR + 1> was_read;
  int cur_unread_notifs = 0, last_notif = 0;
  int sure_first_unread_notif = 1;
  while (q--) {
    int type;
    scanf("%d", &type);
    switch (type) {
      case 1:
        static int x;
        scanf("%d", &x);
        app[x].emplace_back(++last_notif);
        ++cur_unread_notifs;
        break;
      case 2:
        scanf("%d", &x);
        for (auto notif = app[x].rbegin(); notif != app[x].rend(); ++notif) {
          if (!was_read[*notif]) {
            was_read[*notif] = true;
            --cur_unread_notifs;
          }
          app[x].pop_back();
        }
        break;
      default:
        static int t;
        scanf("%d", &t);
        for (; sure_first_unread_notif <= t; ++sure_first_unread_notif) {
          if (!was_read[sure_first_unread_notif]) {
            was_read[sure_first_unread_notif] = true;
            --cur_unread_notifs;
          }
        }
        break;
    }
    printf("%d\n", cur_unread_notifs);
  }
}
