#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  while (a && b) a > b ? a %= b : b %= a;
  return a + b;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long fast_exp(long long base, long long exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1)
      res = ((res % 1000000007) * (base % 1000000007)) % 1000000007;
    base = ((base % 1000000007) * (base % 1000000007)) % 1000000007;
    exp /= 2;
  }
  return res % 1000000007;
}
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
map<int, int> Z;
const int size = 3e5 + 9;
int ptr[size];
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  int unread = 0;
  vector<pair<int, int> > unr;
  int cnt = 0, i = 0;
  while (q--) {
    cnt++;
    int t, x;
    cin >> t >> x;
    if (t == 1) {
      unread++;
      unr.push_back(pair<int, int>(x, cnt));
      Z[x]++;
    } else if (t == 2) {
      unread -= Z[x];
      Z[x] = 0;
      ptr[x] = cnt;
    } else {
      while (i < x) {
        if (unr[i].second >= ptr[unr[i].first]) {
          unread--;
          ptr[unr[i].first] = unr[i].second;
          Z[unr[i].first]--;
        }
        i++;
      }
    }
    cout << unread << '\n';
  }
  return 0;
}
