#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-15;
const double pi = acos(-1.0);
const long long Mod = 1000000007;
const int N = 3e5 + 5;
int ks = 0;
vector<int> pos[N];
bool done[N];
int main() {
  int n, q;
  int ii = 0;
  int now = 0;
  int read = 1;
  scanf("%d%d", &n, &q);
  while (q--) {
    int t, x;
    scanf("%d%d", &t, &x);
    if (t == 1) {
      pos[x].emplace_back(++ii);
      done[ii] = true;
      now++;
    } else if (t == 2) {
      while (pos[x].size()) {
        int p = pos[x].back();
        if (done[p]) {
          now--;
        }
        done[p] = false;
        pos[x].pop_back();
      }
    } else {
      while (x >= read) {
        if (done[read]) {
          done[read] = false;
          now--;
        }
        read++;
      }
    }
    printf("%d\n", now);
  }
}
