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:

  1. +  ai — add non-negative integer ai to the multiset. Note, that she has a multiset, thus there may be many occurrences of the same integer. 
  2. -  ai — delete a single occurrence of non-negative integer ai from the multiset. It's guaranteed, that there is at least one ai in the multiset. 
  3. ? 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 ci — the type of the corresponding operation. If ci is equal to '+' or '-' then it's followed by a space and an integer ai (0 ≤ ai < 1018) given without leading zeroes (unless it's 0). If ci 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. 1 and 241. 
  2. 361. 
  3. 101 and 361. 
  4. 361. 
  5. 4000. 
import java.io.*;
import java.util.*;

public class Main{
	
	public static void main(String[] args) {
		FastScanner3 sc = new FastScanner3(System.in);
		
		int T = sc.nextInt();
		
		Node first = new Node(0);
		
		StringBuilder sb = new StringBuilder();
		
		for(int t = 0 ; t < T ; t++){
			
			String sign = sc.next().trim();
			
			long num = 0;
			if(sign.charAt(0) != '?')
				num = Long.parseLong(sc.next());//sc.nextLong();
			
//			System.out.println(sign + " - " + num);
			if(sign.charAt(0) == '+'){
//				System.out.println("Adding " + num + " to times");
				Node curr = first;
				while(num != 0L){
					long last = num%10;
					if(last%2 == 0){
						if(curr.zero == null){
							curr.zero = new Node(0);
						}
						curr = curr.zero;
					}
					else{
						if(curr.one == null){
							curr.one = new Node(0);
						}
						curr = curr.one;
					}
					num/=10;
				}
				curr.times++;
					
			}
			else if(sign.charAt(0) == '-'){
				Node curr = first;
				while(num != 0){
					long last = num%10;
					if(last%2 == 0){
						curr = curr.zero;
					}
					else{
						curr = curr.one;
					}
					num/=10;
				}
				if(curr.times > 0) curr.times--;
				
			}
			else{
				String pattern = sc.next();
				
				Node curr = first;
				Node prev = null;
				
				int i;
				int size = pattern.length();
				int indexOfOne = pattern.indexOf('1'), limit = 0;
				
				if(indexOfOne != -1){
					limit = size - indexOfOne;
				}
//				System.out.println("For " + pattern + " limit is " + limit);
				
				for(i = 0 ; i < limit && curr != null; i++){
					prev = curr;
					if(pattern.charAt(size-i-1) == '1'){
						curr = curr.one;
					}
					else{
						curr = curr.zero;
					}
				}
				
//				System.out.println("Checking for pattern " + pattern + " at index " + i + " with curr = " + curr);
				int ctr = 0;
				
				if(curr == null){
					i--;
					while(i < size){
						if(pattern.charAt(size - i - 1) == '1') break;
						i++;
					}
					if(i == size) ctr = prev.times;
				}
				else{
//					System.out.println(ctr);
					while(curr != null){
						ctr += curr.times;
						curr = curr.zero;
					}
//					System.out.println(ctr);
				}
				
//				System.out.println("Checking for pattern " + pattern + " at index " + i + " with curr = " + curr);
				sb.append(ctr + "\n");
			}
			
			
		}
		
		System.out.println(sb.toString());
	}
}

class Node{
	int times;
	Node one;	//1
	Node zero;
	
	Node(int time){
		times = time;
	}
}

class FastScanner3{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastScanner3(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    
    public String nextLine()
    {
        int c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }    
    
    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }
    
    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
    
    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }
    
    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}