#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
int n, q;
int lastread[333333];
vector<int> times[333333];
vector<int> firsttype;
int additions = 0;
int thirdtype = 0;
int main() {
  memset(lastread, -1, sizeof(lastread));
  scanf("%d%d", &n, &q);
  int ans = 0;
  for (int(i) = 0; (i) < (q); (i)++) {
    int t;
    scanf("%d", &t);
    if (t == 1) {
      int x;
      scanf("%d", &x);
      times[x].push_back(additions);
      firsttype.push_back(x);
      additions++;
      ans++;
    } else if (t == 2) {
      int x;
      scanf("%d", &x);
      if (times[x].size()) {
        auto it = upper_bound(times[x].begin(), times[x].end(), lastread[x]);
        ans -= (times[x].end() - it);
        lastread[x] = times[x].back();
      }
    } else {
      int tt;
      scanf("%d", &tt);
      for (int j = thirdtype; j < tt; j++) {
        int app = firsttype[j];
        if (lastread[app] < j) {
          lastread[app] = j;
          ans--;
        }
      }
      thirdtype = max(thirdtype, tt);
    }
    printf("%d\n", ans);
  }
  return 0;
}
