stock={}
for item in input().split(','):
k,v=item.strip().split(':')
stock[k.strip()]=int(v.strip())
while True:
line=input().strip()
if line=='END': break
parts=line.split()
cmd,name,qty=parts[0],parts[1],int(parts[2])
if cmd=='sell':
if stock.get(name,0)<qty: print('재고 부족')
else: stock[name]-=qty
else: stock[name]=stock.get(name,0)+qty
for name in sorted(stock):
if stock[name]==0: print(name)