#include <bits/stdc++.h>
using namespace std;
bool vis[305000];
vector<int> g[305000];
int st[305000];
int right2;
int Mright2;
int n, q;
int main() {
  memset(vis, false, sizeof(vis));
  memset(st, 0, sizeof(st));
  scanf("%d%d", &n, &q);
  right2 = 0;
  Mright2 = 0;
  int flag, tmp, ans;
  ans = 0;
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &flag, &tmp);
    if (flag == 1) {
      right2++;
      ans++;
      g[tmp].push_back(right2);
    } else if (flag == 2) {
      for (int j = st[tmp]; j < g[tmp].size(); j++) {
        int v = g[tmp][j];
        if (!vis[v]) {
          vis[v] = true;
          ans--;
        }
      }
      st[tmp] = g[tmp].size();
    } else {
      if (Mright2 < tmp) {
        for (int j = Mright2 + 1; j <= tmp; j++) {
          if (!vis[j]) {
            vis[j] = true;
            ans--;
          }
        }
        Mright2 = tmp;
      }
    }
    printf("%d\n", ans);
  }
}
