#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const int N = 300010;
const long long INF = 1e8;
const long long MOD1 = 998244353;
using namespace std;
bool comp(string a, string b) { return a.size() < b.size(); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector<pair<int, int>> v(q);
  for (int i = 0; i < q; i++) cin >> v[i].first >> v[i].second;
  vector<pair<int, int>> tr;
  int mx = -INF;
  for (int i = 0; i < q; i++) {
    if (v[i].first == 3)
      if (v[i].second > mx) {
        tr.push_back({v[i].second, i});
        mx = v[i].second;
      }
  }
  vector<int> ans(q, 0);
  vector<bool> used(q, 0);
  int sum = 0;
  int i = 0;
  int cnt = 0;
  int pr = -1;
  map<int, int> m;
  for (auto x : tr) {
    int val = x.first;
    int pos = x.second;
    if (pr == -1)
      for (int k = i; k < pos; k++) {
        if (v[k].first == 2) m[v[k].second]++;
      }
    else {
      for (int k = pr; k < pos; k++) {
        if (v[k].first == 2) m[v[k].second]++;
      }
    }
    sum = 0;
    int j;
    for (j = i; j < pos; j++) {
      if (cnt == val) break;
      if (v[j].first == 3)
        continue;
      else if (v[j].first == 2)
        m[v[j].second]--;
      else {
        if (m[v[j].second] == 0) {
          used[j] = 1;
          sum++;
        }
        cnt++;
      }
    }
    ans[pos] = sum;
    i = j;
    sum = 0;
    pr = pos;
  }
  sum = 0;
  map<int, int> m1;
  for (int j = 0; j < q; j++) {
    if (v[j].first == 3) {
      ans[j] = sum - ans[j];
      sum = ans[j];
    } else {
      if (v[j].first == 1) {
        sum++;
        if (!used[j]) m1[v[j].second]++;
      } else {
        sum -= m1[v[j].second];
        m1[v[j].second] = 0;
      }
      ans[j] = sum;
    }
  }
  for (auto x : ans) cout << x << endl;
  return 0;
}
