Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type:   +  a_{i} — add non-negative integer a_{i} to the multiset. Note, that she has a multiset, thus there may be many occurrences of the same integer.   -  a_{i} — delete a single occurrence of non-negative integer a_{i} from the multiset. It's guaranteed, that there is at least one a_{i} in the multiset.  ? s — count the number of integers in the multiset (with repetitions) that match some pattern s consisting of 0 and 1. In the pattern, 0 stands for the even digits, while 1 stands for the odd. Integer x matches the pattern s, if the parity of the i-th from the right digit in decimal notation matches the i-th from the right digit of the pattern. If the pattern is shorter than this integer, it's supplemented with 0-s from the left. Similarly, if the integer is shorter than the pattern its decimal notation is supplemented with the 0-s from the left. 

For example, if the pattern is s = 010, than integers 92, 2212, 50 and 414 match the pattern, while integers 3, 110, 25 and 1030 do not.


-----Input-----

The first line of the input contains an integer t (1 ≤ t ≤ 100 000) — the number of operation Sonya has to perform.

Next t lines provide the descriptions of the queries in order they appear in the input file. The i-th row starts with a character c_{i} — the type of the corresponding operation. If c_{i} is equal to '+' or '-' then it's followed by a space and an integer a_{i} (0 ≤ a_{i} < 10^18) given without leading zeroes (unless it's 0). If c_{i} equals '?' then it's followed by a space and a sequence of zeroes and onse, giving the pattern of length no more than 18.

It's guaranteed that there will be at least one query of type '?'.

It's guaranteed that any time some integer is removed from the multiset, there will be at least one occurrence of this integer in it.


-----Output-----

For each query of the third type print the number of integers matching the given pattern. Each integer is counted as many times, as it appears in the multiset at this moment of time.


-----Examples-----
Input
12
+ 1
+ 241
? 1
+ 361
- 241
? 0101
+ 101
? 101
- 101
? 101
+ 4000
? 0

Output
2
1
2
1
1

Input
4
+ 200
+ 200
- 200
? 0

Output
1



-----Note-----

Consider the integers matching the patterns from the queries of the third type. Queries are numbered in the order they appear in the input.   1 and 241.  361.  101 and 361.  361.  4000.

Difficulty: competition

Starter code:

Solutions:
from sys import stdin


def main():
    cnt = [0] * 2 ** 18
    t = str.maketrans("0123456789", "0101010101")
    _, *l = stdin.read().splitlines()
    for sign, s in map(str.split, l):
        if sign == '?':
            print(cnt[int(s, 2)])
        else:
            cnt[int(s.translate(t), 2)] += 1 if sign == '+' else -1


def __starting_point():
    main()

__starting_point()

#!/usr/bin/env	python
#-*-coding:utf-8 -*-
t=str.maketrans('0123456789','0101010101')
C=(1<<18)*[0]
for _ in range(int(input())):
	c,a=input().split()
	if'?'==c:print(C[int(a,2)])
	else:C[int(a.translate(t),2)]+=1 if'-'!=c else-1


#!/usr/bin/env	python
#-*-coding:utf-8 -*-
t=str.maketrans('0123456789','0101010101')
C=(1<<18)*[0]
for _ in range(int(input())):
	c,a=input().split()
	if'?'==c:print(C[int(a,2)])
	else:C[int(a.translate(t),2)]+=1 if'-'!=c else-1



def convert(strVal):
    
    ls = list()
    for c in strVal:
        if (ord(c)&1):
            ls.append('1')
        else:
            ls.append('0')
    
    
    a = ''.join(ls)
    
    
    
    
    
    '''strLength = len(strVal)
    a='0'*strLength
    
    
    i=strLength-1
    
    
    while i>=0:
        
        divByTwo =''
        
        if (ord(strVal[i])&1):
            divByTwo='1'
        else:
            divByTwo='0'
        
        if i==(strLength-1):
            a= a[:i] +divByTwo
        elif i==0:
            a= divByTwo + a[1:]
        else:
            a = a[:i]+divByTwo+a[i+1:]
        
        i-=1'''
        #aLength-=1
    
    return int(a)

from collections import defaultdict
inputList=defaultdict(int)

inputNum = int(input())

#print (inputNum)

#iterate n times and do changes in each iteration
for  x in range(0,inputNum):
    inputStr=input()
    
    firstValue = inputStr[0]
    secondValue = inputStr[2:]
    
    if firstValue!='?':
        convertedValue = convert(secondValue)
        #print(secondValue)
        #print(convertedValue)
    #print (convertedValue)
    
    # + case
    if firstValue=='+':
        #plusVal = int(convertedValue)
        inputList[convertedValue]+=1
    
    # - case
    elif firstValue=='-':
        #minusVal = int(convertedValue)
        inputList[convertedValue]-=1
    
    # ? case
    elif firstValue=='?':
        patString = int(secondValue)
        count=inputList[patString]
        print(count)                    
        
 
#print(inputList) 
       
#print(inputList)        
'''for x in inputList:
    print('{}, {}', x, inputList[x])'''
        
        




t=int(input())
T=str.maketrans('0123456789','0101010101')
l=[0]*300000
for _ in ' '*t:
    a,b=input().split()
    if a=='?':print(l[int(b,2)])
    else:l[int(b.translate(T),2)]+=1if a=='+'else -1

t=int(input())
T=str.maketrans('0123456789','0101010101')
d={}
for _ in ' '*t:
    a,b=input().split()
    b=int(b.translate(T))
    if a=='?':print(d.get(b,0))
    elif a=='+':d[b]=d.get(b,0)+1
    else:d[b]-=1

t=int(input())
T=str.maketrans('0123456789','0101010101')
d={}
for _ in ' '*t:
    a,b=input().split()
    b=int(b.translate(T))
    if a=='?':print(d.get(b,0))
    elif a=='+':d[b]=d.get(b,0)+1
    else:d[b]-=1

n = int(input())
a = []
wk1 = "0" * 18
rules = str.maketrans("0123456789", "0101010101")
trans = lambda x : str.translate(x, rules)
d = {}
for _ in range(n):
    x, y = input().split()
    y = int(trans(y), 2)
    if x == "+":
        d[y] = d.get(y, 0) + 1
    elif x == "-":
        d[y] -= 1
    elif x == "?":
        print(d.get(y, 0))




cnt = [0]*262200
trans = str.maketrans('0123456789', '0101010101')
t = int(input())
for _ in range(t):
    o, a = input().split()

    if o == '+':
        cnt[int(a.translate(trans), 2)] += 1
    elif o == '-':
        cnt[int(a.translate(trans), 2)] -= 1
    else:
        print(cnt[int(a, 2)])


n = int(input())

d = {}

def get_mask(num):
    res = ''
    for el in num:
        if (int(el) & 1):
            res += '1'
        else:
            res += '0'

    return '0' * (18 - len(num)) + res
    

for _ in range(n):
    c, v = input().split(' ')
    if c == '?':
        v = '0' * (18 - len(v)) + v
        if v in d.keys():
            print(d[v])
        else:
            print(0)
    elif c == '+':
        v = get_mask(v)
        if v in d.keys():
            d[v] += 1
        else:
            d[v] = 1
    else:
        v = get_mask(v)
        d[v] -= 1

n = int(input())

d = {}

def get_mask(num):
    res = ''
    for el in num:
        if (int(el) & 1):
            res += '1'
        else:
            res += '0'

    return '0' * (18 - len(num)) + res
    

for _ in range(n):
    c, v = input().split(' ')
    if c == '?':
        v = '0' * (18 - len(v)) + v
        
        if d.get(v) != None:
            print(d[v])
        else:
            print(0)
    elif c == '+':
        v = get_mask(v)
        if d.get(v) != None:
            d[v] += 1
        else:
            d[v] = 1
    else:
        v = get_mask(v)
        d[v] -= 1

from collections import defaultdict
class trie:
    def __init__(self):
        self.nodes1,self.nodes2 = None,None
        self.count1,self.count2 = 0,0

    def add(self,s,i):
        if i>=len(s):
            return
        md = int(s[i])%2
        if md==0:
            if not self.nodes1:
                self.nodes1 = trie()

            self.count1 += 1
            self.nodes1.add(s,i+1)
        else:
            if not self.nodes2:
                self.nodes2 = trie()

            self.count2 += 1
            self.nodes2.add(s,i+1)
    
    def remove(self,s,i):
        if i>=len(s):
            return
        md = int(s[i])%2
        if md==0:
            self.count1 -= 1
            self.nodes1.remove(s,i+1)
            if self.count1==0:
                self.nodes1 = None
        else:
            self.count2 -= 1
            self.nodes2.remove(s,i+1)
            if self.count2==0:
                self.nodes2 = None
    
    def search(self,s,i,mn):
        if i>=len(s):
            return mn
        md = int(s[i])%2
        if md==0:
            if self.nodes1:
                return self.nodes1.search(s,i+1,min(mn,self.count1))
            else:
                return 0
        else:
            if self.nodes2:
                return self.nodes2.search(s,i+1,min(mn,self.count2))
            else:
                return 0



t = int(input())
# tr = trie()
st = set('02468')
mp = defaultdict(int)
res = []
while t>0:
    t-=1
    c,s = input().split()
    # s = s.zfill(18)
    if c=='+':
        # ss = [str(int(i)%2) for i in s]
        ss = ''
        for i in s:
            if i in st:
                ss += '0'
            else:
                ss += '1'

        # ss = ''.join(ss)
        mp[int(ss,2)]+=1
        # print('**',ss,int(ss,2))
        # tr.add(s,0)
    elif c=='-':
        # ss = [str(int(i)%2) for i in s]
        # ss = ''.join(ss)
        ss = ''
        for i in s:
            if i in st:
                ss += '0'
            else:
                ss += '1'
        mp[int(ss,2)]-=1
        # tr.remove(s,0)
    elif c=='?':
        # v = tr.search(s,0,10**6)
        # print(v)
        # print('##',ss,int(ss,2))
        res.append(mp[int(s,2)])

print(*res,sep='\n')

t = int(input())
rules = str.maketrans("0123456789", "0101010101")
trans = lambda x : str.translate(x, rules)
cnt, res = {}, []
for _ in range(t):
    op, n = input().split()
    n = int(trans(n), 2)
    if op == '+':
        cnt[n] = cnt.get(n, 0) + 1
    elif op == '-':
        cnt[n] -= 1
    else:
        print(cnt.get(n, 0))


t = int(input())
rules = str.maketrans("0123456789", "0101010101")
trans = lambda x : str.translate(x, rules)
cnt, res = {}, []
for _ in range(t):
    op, n = input().split()
    n = int(trans(n), 2)
    if op == '+':
        cnt[n] = cnt.get(n, 0) + 1
    elif op == '-':
        cnt[n] -= 1
    else:
        res.append(str(cnt.get(n, 0)))
print('\n'.join(res))


from sys import stdin
d,res,elem={},'','0101010101'
for _ in range(int(stdin.readline())):
    c,x=map(str,stdin.readline().split())
    if c!='?':
        x=[*x]
        x=[elem[int(y)] for i,y in enumerate(x)]
        x=''.join(x)
    x=x[x.find('1'):]
    if c=='+':
        if d.get(x)==None:d[x]=0
        d[x]+=1
    elif c=='-':d[x]-=1
    else:
        if d.get(x)==None:res+='0'+'\n'
        else:res+=str(d[x])+'\n'
print(res)

from sys import stdin
d,res,elem={},'','0101010101'
a=lambda:stdin.readline().split()
for _ in range(int(stdin.readline())):
    c,x=map(str,a())
    if c!='?':
        x=[*x]
        x=[elem[int(y)] for i,y in enumerate(x)]
        x=''.join(x)
    x=x[x.find('1'):]
    if c=='+':
        if d.get(x)==None:d[x]=0
        d[x]+=1
    elif c=='-':d[x]-=1
    else:
        if d.get(x)==None:res+='0'+'\n'
        else:res+=str(d[x])+'\n'
print(res)

LVL = 18
from collections import defaultdict


def pattern_repr(x):
    rep = [1 if int(x) % 2 else 0 for x in x]
    return [0] * (LVL - len(rep)) + rep


class Node:
    def __init__(self, key, node_id=0):
        self.key = key
        self.node_id = node_id
        self.left = None
        self.right = None


class CodeforcesTask713ASolution:
    def __init__(self):
        self.result = ''
        self.t = 0
        self.queries = []

    def read_input(self):
        self.t = int(input())
        for _ in range(self.t):
            self.queries.append(input().split(" "))

    def process_task(self):
        res = []
        root = Node(0, 1)
        node_id = 2
        treesol = False
        if treesol:
            for query in self.queries:
                if query[0] in "+-":
                    pattern = pattern_repr(query[1])
                    #print(pattern)
                    current = root
                    while pattern:
                        #print(current.node_id)
                        if pattern[0]:
                            # going right
                            if current.right:
                                current = current.right
                            else:
                                current.right = Node(0, node_id)
                                current = current.right
                                node_id += 1
                        else:
                            # going left
                            if current.left:
                                current = current.left
                            else:
                                current.left = Node(0, node_id)
                                current = current.left
                                node_id += 1
                        pattern = pattern[1:]
                    current.key += 1 if query[0] == "+" else -1
                    #print(current.key, current.node_id)
                else:
                    pattern = [int(x) for x in "0" * (LVL - len(query[1])) + query[1]]
                    current = root
                    #print(pattern)
                    while pattern:
                        if pattern[0]:
                            # going right
                            if current.right:
                                current = current.right
                            else:
                                current = Node(0)
                                pattern = []
                        else:
                            # going left
                            if current.left:
                                current = current.left
                            else:
                                current = Node(0)
                                pattern = []
                        pattern = pattern[1:]
                    res.append(current.key)
        else:
            counts = defaultdict(int)
            for query in self.queries:

                if query[0] in "+-":
                    pattern = "0" * (LVL - len(query[1])) + "".join(("1" if int(x) % 2 else "0" for x in query[1]))
                    counts[pattern] += 1 if query[0] == "+" else -1
                else:
                    pattern = "0" * (LVL - len(query[1])) + query[1]
                    res.append(counts[pattern])

        self.result = "\n".join([str(x) for x in res])

    def get_result(self):
        return self.result


def __starting_point():
    Solution = CodeforcesTask713ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

__starting_point()

# -*- coding: utf-8 -*-

# Baqir Khan
# Software Engineer (Backend)

from collections import defaultdict
from sys import stdin

inp = stdin.readline


def convert_num(number):
    number_list = list(map(int, number))
    res = "".join(str(d & 1) for d in number_list)
    return "0" * (18 - len(res)) + res


def convert_pattern(pattern):
    return "0" * (18 - len(pattern)) + pattern


t = int(inp())
multiset = defaultdict(int)

while t:
    t -= 1
    op, item = inp().split()
    if op == "+":
        multiset[convert_num(item)] += 1
    elif op == "-":
        multiset[convert_num(item)] -= 1
    else:
        print(multiset[convert_pattern(item)])