#include using namespace std; typedef long long int ll; typedef pair P; typedef pair Pll; typedef vector Vi; //typedef tuple T; #define FOR(i,s,x) for(int i=s;i<(int)(x);i++) #define REP(i,x) FOR(i,0,x) #define ALL(c) c.begin(), c.end() #define DUMP( x ) cerr << #x << " = " << ( x ) << endl const int dr[4] = {-1, 0, 1, 0}; const int dc[4] = {0, 1, 0, -1}; const ll INF = 1e18; int main() { int Q; scanf("%d", &Q); vector labo_members; REP(q, Q) { int t; ll x; scanf("%d %lld", &t, &x); if (t == 1) { labo_members.emplace_back(x); } else if (t == 2) { x--; assert(labo_members[(int)x] != INF); labo_members[(int)x] = INF; } else if (t == 3) { REP(i, labo_members.size()) { if (labo_members[i] != INF) labo_members[i] += x; } } vector members; for (ll x : labo_members) { if (x != INF) members.emplace_back(x); } sort(ALL(members), greater()); bool flag = false; REP(i, members.size()) { if ((ll)i + 1 > members[i]) { printf("%d\n", i); flag = true; break; } } if (not flag) { printf("%d\n", (int)members.size()); } } return 0; }