range(1,n):
if int(a[i-1])>=x:
b.append(b[i-1]+1)
else:
b.append(b[i-1])
k=int(input.readline().rstrip())
smesh=0
for i in range(k):
rab=input.readline()
rab=rab.rstrip()
if rab[0]=='2':
smesh+=1
elif rab[0]=='1':
e=int(rab[2:])
if int(a[-1])>=x:
b.append(b[-1]+1)
else:
b.append(b[-1])
a.append(e)
else:
otv=b[int(rab[2:])+smesh]-b[smesh]
output.write(str(otv)+'\n')
f = open ("longqueue.in", "r")
n, x = [int(x) for x in f.readline().split()]
bb = [int(x) for x in f.readline().split()]
d = 0
a = [0]
for b in bb:
if b >= x:
d += 1
a.append ( d)
m_count = int (f.readline())
result = []
h = 0 # head person position
for i in range (m_count):
m = f.readline().split()
if m[0] == '1':
if int (m[1]) >= x:
a.append(a[-1] + 1)
else:
a.append(a[-1])
elif m[0] == '2':
h = h + 1
elif m[0] == '3':
r = a[int (m[1]) + h] - a[h]
result.append(r)
print (r)
f.close
with open("longqueue.out", "w") as f:
for r in result:
f.write(str(r)+'\n')