#include <bits/stdc++.h>
using namespace std;
int const limit = 300100;
static set<int> apps[limit];
static int notifications[limit];
static int numof_notifications;
static int first_unread_i;
static int numof_unread;
int main() {
  ios_base::sync_with_stdio(false);
  int n = 0;
  int q = 0;
  cin >> n >> q;
  for (int i = 0; i < q; ++i) {
    int type = 0;
    int read = 0;
    int app = 0;
    cin >> type;
    switch (type) {
      case 1:
        cin >> app;
        apps[app].insert(numof_notifications);
        notifications[numof_notifications++] = app;
        cout << ++numof_unread << '\n';
        break;
      case 2:
        cin >> app;
        numof_unread -= apps[app].size();
        apps[app].clear();
        cout << numof_unread << '\n';
        break;
      case 3:
        cin >> read;
        for (int j = first_unread_i; j < read; ++j) {
          if (apps[notifications[j]].erase(j)) {
            --numof_unread;
          }
        }
        first_unread_i = max(first_unread_i, read);
        cout << numof_unread << '\n';
        break;
    }
  }
}
