import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
md = 10**9+7
# md = 998244353

from heapq import *

class RemovableHeap:
    def __init__(self):
        self.hp = []
        self.rem = []
        self.s = {}
        self.size = 0

    def __len__(self): return self.size

    def __getitem__(self, i):
        if i: return None
        self.__trim()
        return self.hp[0]

    def push(self, val):
        heappush(self.hp, val)
        if val in self.s: self.s[val] += 1
        else: self.s[val] = 1
        self.size += 1
        return True

    def pop(self):
        self.__trim()
        if not self.hp: return None
        self.size -= 1
        val = heappop(self.hp)
        if self.s[val] == 1: del self.s[val]
        else: self.s[val] -= 1
        return val

    def remove(self, val):
        if val not in self.s: return False
        self.size -= 1
        if self.s[val] == 1: del self.s[val]
        else: self.s[val] -= 1
        heappush(self.rem, val)
        return True

    def __trim(self):
        while self.rem and self.rem[0] == self.hp[0]:
            heappop(self.hp)
            heappop(self.rem)

ll = RemovableHeap()
rr = RemovableHeap()

q = II()
base = 0
xx = []
for _ in range(q):
    t, x = LI()
    if t == 1:
        x -= base
        if len(rr) and x >= rr[0]: rr.push(x)
        else: ll.push(-x)
        xx.append(x)
    if t == 2:
        x = xx[x-1]
        if len(rr) and x >= rr[0]: rr.remove(x)
        else: ll.remove(-x)
    if t == 3:
        base += x

    while len(ll) and -ll[0]+base > len(rr):
        x = -ll.pop()
        rr.push(x)
    while len(rr) and rr[0]+base < len(rr):
        x = rr.pop()
        ll.push(-x)
    print(len(rr))