#include <bits/stdc++.h>
using namespace std;
void debug(int* a, int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << '\n';
}
void debug(vector<int> b, int n) {
  for (int i = 0; i < n; i++) cout << b[i] << " ";
  cout << '\n';
}
const long long INF = 1e18;
const int inf = 1e9;
int main() {
  ios_base::sync_with_stdio(false);
  int n, q, i, j, t1, t2, unvis = 0, t = 0;
  cin >> n >> q;
  int a[n + 5];
  vector<int> me[n + 5];
  int vis[q + 5];
  for (i = 0; i < q; i++) vis[i] = 0;
  for (i = 0; i < n + 2; i++) a[i] = 0;
  vector<pair<int, int> > qu;
  for (i = 0; i < q; i++) {
    cin >> t1 >> t2;
    if (t1 == 1) {
      unvis++;
      cout << unvis << endl;
      me[t2].push_back(i);
      qu.push_back(make_pair(t2, i));
      continue;
    }
    if (t1 == 2) {
      int p = a[t2];
      for (j = p; j < me[t2].size(); j++) {
        if (vis[me[t2][j]] == 0) {
          vis[me[t2][j]] = 1;
          unvis--;
        }
      }
      a[t2] = me[t2].size() - 1;
      a[t2] = max(a[t2], 0);
      cout << unvis << endl;
      continue;
    }
    for (j = t; j <= t2 - 1; j++) {
      int x = qu[j].second;
      if (vis[x] == 0) {
        vis[x] = 1;
        unvis--;
      }
    }
    cout << unvis << endl;
    t = max(t, t2 - 1);
  }
  return 0;
}
