#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& cout, const vector<T>& a) {
  if ((int)a.size() == 0) {
    return (cout << "()");
  }
  cout << "(" << a[0];
  for (int i = 1; i < (int)a.size(); i++) {
    cout << "; " << a[i];
  }
  return (cout << ")");
}
template <typename T>
ostream& operator<<(ostream& cout, const set<T>& a) {
  if ((int)a.size() == 0) {
    return (cout << "{}");
  }
  auto it = a.begin();
  cout << "{" << *it;
  ++it;
  for (; it != a.end(); ++it) {
    cout << "; " << *it;
  }
  return (cout << "}");
}
template <typename T>
ostream& operator<<(ostream& cout, const multiset<T>& a) {
  if ((int)a.size() == 0) {
    return (cout << "{}");
  }
  auto it = a.begin();
  cout << "{" << *it;
  ++it;
  for (; it != a.end(); ++it) {
    cout << "; " << *it;
  }
  return (cout << "}");
}
template <typename T1, typename T2>
ostream& operator<<(ostream& cout, const pair<T1, T2>& a) {
  return cout << "(" << a.first << "; " << a.second << ")";
}
const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const long long infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const long double pi = acos(-1.0);
int n, q, t, x, sz[nmax], cnt[nmax], ans = 0, lst[nmax];
vector<pair<int, int> > a;
int main() {
  cin >> n >> q;
  int l = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &t, &x);
    if (t == 1) {
      x--;
      sz[x]++;
      a.push_back(make_pair(x, sz[x]));
      cnt[x]++;
      ans++;
    } else if (t == 2) {
      x--;
      ans -= cnt[x];
      cnt[x] = 0;
      lst[x] = sz[x];
    } else {
      while (l < x) {
        if (lst[a[l].first] >= a[l].second) {
          l++;
          continue;
        }
        cnt[a[l].first]--;
        l++;
        ans--;
      }
    }
    cout << ans << endl;
  }
}
