#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
int unread = 0;
queue<int> a[300007];
queue<pair<int, int>> notif;
bool visited[300007];
int idx = 1;
void compute(int t, int x) {
  if (t == 1) {
    notif.push({idx, x});
    a[x].push(idx);
    idx++;
    unread++;
  } else if (t == 2) {
    while (!a[x].empty()) {
      if (visited[a[x].front()] == 0) {
        unread--;
        visited[a[x].front()] = 1;
      }
      a[x].pop();
    }
  } else {
    while (!notif.empty() && notif.front().first <= x) {
      int i = notif.front().first;
      int app = notif.front().second;
      notif.pop();
      while (!a[app].empty() && a[app].front() <= i) {
        unread--;
        visited[a[app].front()] = 1;
        a[app].pop();
      }
    }
  }
  cout << unread << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(visited, 0, sizeof visited);
  int n, q;
  cin >> n >> q;
  int t, x;
  for (int i = 1; i <= q; i++) {
    cin >> t >> x;
    compute(t, x);
  }
}
