#include <bits/stdc++.h>
using namespace std;
template <class T, class X>
inline bool checkbit(T a, X pos) {
  T t = 1;
  return ((a & (t << pos)) > 0);
}
template <class T, class X>
inline T setbit(T a, X pos) {
  T t = 1;
  return (a | (t << pos));
}
template <class T, class X>
inline T resetbit(T a, X pos) {
  T t = 1;
  return (a & (~(t << pos)));
}
template <class T, class X>
inline T togglebit(T a, X pos) {
  T t = 1;
  return (a ^ (t << pos));
}
template <typename T>
T POW(T base, T power) {
  T ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base);
    base = (base * base);
    power >>= 1;
  }
  return ret;
}
template <typename T>
T PPOW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return ((POW(B, P / 2)) * (POW(B, P / 2)));
}
template <typename T>
T Bigmod(T base, T power, T mod) {
  T ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % mod;
    base = (base * base) % mod;
    power >>= 1;
  }
  return ret;
}
template <typename T>
T ModInverse(T number, T mod) {
  return Bigmod(number, mod - 2, mod);
}
template <typename T>
T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (b == 0) ? a : GCD(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return a * (b / GCD(a, b));
}
template <typename T>
T EUCLIDE(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
template <typename T>
T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
template <typename T>
double DIS(T x1, T y1, T x2, T y2) {
  return sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
}
template <typename T>
T ANGLE(T x1, T y1, T x2, T y2) {
  return atan(double(y1 - y2) / double(x1 - x2));
}
template <typename T>
long long isLeft(T a, T b, T c) {
  return (c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y);
}
void P_ARR(int *ar, int a, int b) {
  if (a > b) swap(a, b);
  if (a <= b) cout << ar[a];
  for (int i = a + 1; i <= b; i++) cout << " " << ar[i];
  cout << endl;
}
template <typename T>
T In() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
int ar[300007];
int br[300007];
int aa[300007];
int vis[300007];
vector<int> pos[300007];
int main() {
  int n, q;
  scanf("%d%d", &(n), &(q));
  int tot = 0;
  int id = 0;
  int ptr = 1;
  for (int i = 1; i <= q; i++) {
    int cmd;
    scanf("%d", &(cmd));
    ;
    int x;
    scanf("%d", &(x));
    ;
    if (cmd == 1) {
      ar[x]++;
      tot++;
      aa[++id] = x;
      pos[x].push_back(id);
    } else if (cmd == 2) {
      tot -= (ar[x] - br[x]);
      while (br[x] < ar[x]) {
        br[x]++;
        int p = pos[x][br[x] - 1];
        vis[p] = 1;
      }
    } else {
      while (ptr <= x) {
        if (vis[ptr] == 0) tot--, br[aa[ptr]]++;
        ptr++;
      }
    }
    printf("%d\n", tot);
  }
  return 0;
}
