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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class Solution123{
	//static int[] arr;
	static int[] sp;
	//static char[] m;
	//static ArrayList<Integer> arr5;
	static int coun = 0;
	public static void main(String[] args) throws IOException{
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		TreeMap<String,Long> tmap = new TreeMap();
		while(n-- > 0){
			String s = sc.next();
			String st = sc.next();
			switch(s.charAt(0)){
				case '+':
					if(st.length() < 19){
						while(st.length() < 19){
							st = "0" + st;
						}
					}
					char[] cha=  st.toCharArray();
					String a = "";
					for(char ch: cha){
						a = a +((long)(ch -'0')%2);
					}
					if(!tmap.containsKey(a)){
						tmap.put(a,(long) 1);
					}else{
						tmap.put(a, tmap.get(a) + 1);
					}
					break;
				case '-':
					if(st.length() < 19){
						while(st.length() < 19){
							st = "0" + st;
						}
					}
					char[] cha1=  st.toCharArray();
					String a1 = "";
					for(char ch: cha1){
						a1 = a1 +((long)(ch -'0')%2);
					}
					if(tmap.get(a1) == 1){
						tmap.remove(a1);
					}else{
						tmap.put(a1, tmap.get(a1) - 1);
					}
					break;
				case '?':
					while(st.length()<19){
						st="0"+st;
					}
					if(tmap.containsKey(st))
						System.out.println(tmap.get(st));
					else
						System.out.println("0");
					break;
			}
		}
	}
	static class MyDS
	{
		   ArrayList<Long> arr;   // A resizable array
		 
		   // A hash where keys are array elements and vlaues are
		   // indexes in arr[]
		   HashMap<Long, Integer>  hash;
		 
		   // Constructor (creates arr[] and hash)
		   public MyDS()
		   {
		       arr = new ArrayList();
		       hash = new HashMap<Long, Integer>();
		   }
		 
		   // A Theta(1) function to add an element to MyDS
		   // data structure
		   void add(long x)
		   {
		      // If ekement is already present, then noting to do
		      if (hash.get(x) != null)
		          return;
		 
		      // Else put element at the end of arr[]
		      int s = arr.size();
		      arr.add(x);
		 
		      // And put in hash also
		      hash.put(x, s);
		   }
		 
		   // A Theta(1) function to remove an element from MyDS
		   // data structure
		   void remove(Long x)
		   {
		       // Check if element is present
		       Integer index = hash.get(x);
		       if (index == null)
		          return;
		 
		       // If present, then remove element from hash
		       hash.remove(x);
		 
		       // Swap element with last element so that remove from
		       // arr[] can be done in O(1) time
		       int size = arr.size();
		       Long last = arr.get(size-1);
		       Collections.swap(arr, index,  size-1);
		 
		       // Remove last element (This is O(1))
		       arr.remove(size-1);
		 
		       // Update hash table for new index of last element
		       hash.put(last, index);
		    }
		 
		    // Returns a random element from MyDS
		    Long getRandom()
		    {
		       // Find a random index from 0 to size - 1
		       Random rand = new Random();  // Choose a different seed
		       int index = rand.nextInt(arr.size());
		 
		       // Return element at randomly picked index
		       return arr.get(index);
		    }
		 
		    // Returns index of element if element is present, otherwise null
		    Integer search(int x)
		    {
		       return hash.get(x);
		    }
		    long answer(String pattern){
		    	long count = 0;
		    	for(int i = 0;i < arr.size();i++){
		    		if(pat(arr.get(i),pattern)){
		    			count++;
		    		}
		    	}
		    	return count;
		    }
		    boolean pat(Long l,String pattern){
		    	StringBuilder st = new StringBuilder();
		    	while(l != 0){
		    		long z = l % 10;
		    		st.append(z);
		    		l = l/10;
		    		if(st.length() == pattern.length()){
		    			break;
		    		}
		    	}
		    	if(st.length() != pattern.length()){
		    		while(pattern.length() != st.length()){
		    			st.append("0");
		    		}
		    	}
		    	st.reverse();
		    	if(st.toString().equals(pattern)){
		    		return true;
		    	}
		    	return false;
		    }
		}
	static long subset(long[] arr){
		int n = arr.length;
		long answer = 0;
		for(int i = 0;i < (1<<n);i++){
			//ArrayList<Integer> a1 = new ArrayList();
			long max = Long.MIN_VALUE;
			long min = Long.MAX_VALUE;
			for(int j = 0;j < n;j++){
				if ((i & (1 << j)) > 0){
					//System.out.print(arr[j] + " ");
					if(arr[j] > max){
						max = arr[j];
					}if(arr[j] < min){
						min = arr[j];
					}
				}
			}
			//System.out.println();
			//System.out.println(min + " " + max);
			if(max != Long.MIN_VALUE && min != Long.MAX_VALUE){
				answer += (max - min);
				answer = (answer + 1000000007) % 1000000007;
			}
			
		}
		return answer;
	}
	static Set<String> substring(String A){
		Set<String> arr = new HashSet();
		for (int i = 0; i < A.length(); i++) {
	        for (int j = i+1; j <= A.length(); j++) {
	            if(isPalindrome(A.substring(i,j))){
	            	arr.add(A.substring(i,j));
	            }
	        }
	    }
		return arr;
	}
	static boolean isPalindrome(String s) {
		  int n = s.length();
		  for (int i = 0; i < (n/2); ++i) {
		     if (s.charAt(i) != s.charAt(n - i - 1)) {
		         return false;
		     }
		  }

		  return true;
	}
	static class Pair implements Comparable<Pair>{
		int indexI;
	    //int indexJ;
		Long value;
		//Integer tempvalue;
		Long profit;
		Pair(){}
		Pair(int indexI,long value){
			this.indexI = indexI;
			//this.indexJ = indexJ;
			this.value = value;
			//this.tempvalue = value;
		}
		public int compareTo(Pair o) {
			return  o.profit.compareTo(profit);
		}
	}
	static String generator(int length){
		StringBuilder st = new StringBuilder("");
		int min = 97;
		int max = 99;
		for(int i = 0;i < length;i++){
			Random rand = new Random();
			st.append((char)(rand.nextInt((max - min) + 1) + min));
		}
		return st.toString();
	}
	static void seive(){
		for(int i = 4;i < sp.length;i += 2){
			sp[i] = 2;
		}
	    for (int i=3; i*i<sp.length; i++)
	    {
	        
	        if (sp[i] == i)
	        {
	            for (int j=i*i; j<sp.length; j+=i)
	                if (sp[j]==j)
	                    sp[j] = i;
	        }
	    }
	}

	public static StringBuilder stringMaker(int n){
		StringBuilder st = new StringBuilder("");
		String s = "aabb";
		int t = n;
		while(t > 3){
			st.append(s);
			t = t - 4;
		}
		s = s.substring(0,t);
		st.append(s);
		return st;
	}
	public static boolean[] sieveAlgo(int n){
		boolean isPrime[] = new boolean[n + 1];
		for (int i = 2; i <= n; i++) {
            isPrime[i] = true;
        }

        // mark non-primes <= n using Sieve of Eratosthenes
        for (int factor = 2; factor*factor <= n; factor++) {

            // if factor is prime, then mark multiples of factor as nonprime
            // suffices to consider mutiples factor, factor+1, ...,  n/factor
            if (isPrime[factor]) {
                for (int j = factor; factor*j <= n; j++) {
                    isPrime[factor*j] = false;
                }
            }
        }
        return isPrime;
	}
	public static int binarySearch(int[] arr,int low,int high,int key){
		while(low <= high){
			int mid = (low + high)/2;
			if(arr[mid] == key){
				return mid;
			}else if(arr[mid] < key){
				low = mid + 1;
			}else{
				high = mid - 1;
			}
		}
		return -1;
	}
	public static int ternarySearch(int[] arr,int l,int r,int key){
		if(r >= l){
			int mid1 = l + (r-1)/3;
			int mid2 = r - (r-1)/3;
			if(arr[mid1] == key){
				return mid1;
			}else if(arr[mid2] == key){
				return mid2;
			}
			if(key < arr[mid1]){
				return ternarySearch(arr,l,mid1-1,key);
			}else if(key > arr[mid2]){
				return ternarySearch(arr,mid2 + 1,r,key);
			}else{
				return ternarySearch(arr,mid1 + 1,mid2 - 1,key);
			}
		}
		return -1;
	}
	public static double fun(double x){
		return 2 * x * x - 12 * x + 7;
	}
	
	public static double tsModified(double start,double end){
		double l = start;
		double r = end;
		for(int i = 0;i < 200;i++){
			double mid1 = (l * 2 + r)/3;
			double mid2 = (l + 2 * r)/3;
			if(fun(mid1) < fun(mid2)){
				r = mid2;
			}else{
				l = mid1;
			}
		}
		double x = l;
		return fun(x);
	}
	public static String fmt(double d)
	{
	    if(d == (long) d)
	        return String.format("%d",(long)d);
	    else
	        return String.format("%s",d);
	}
	public static int[][] comparator(int[][] arr){
		Arrays.sort(arr, new Comparator<int[]>() {
            @Override
            public int compare(int[] a,int[] b) {
                Integer a1 = a[1];
                Integer b1 = b[1];
            	return b1.compareTo(a1);
            }
        });
		return arr;
	}
	public static int[][] comparator2(int[][] arr){
		Arrays.sort(arr, new Comparator<int[]>() {
            @Override
            public int compare(int[] a,int[] b) {
                Integer a1 = a[0];
                Integer b1 = b[0];
            	return b1.compareTo(a1);
            }
        });
		return arr;
	}
	public static Pair[][] comparator2(Pair[][] arr){
		Arrays.sort(arr, new Comparator<Pair[]>() {
           	@Override
			public int compare(Pair[] o1, Pair[] o2) {
				// TODO Auto-generated method stub
				Pair p1 = o1[0];
				Pair p2 = o2[0];
				return p2.compareTo(p1);
			}
        });
		return arr;
	}
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	public static String min(int m,int n){
		int[] arr = new int[m];
		arr[0] = 1;
		int sum = 1;
		int j = m - 1;
		for(int i = 1;i <= 18* m + 10;i++){
			if(sum != n){
				if(arr[j] == 9){
					j--;
				}else{
					arr[j]++;
					sum++;
				}
			}
			else{
				break;
			}
		}
		StringBuilder min = new StringBuilder("");
		for(int i = 0;i < arr.length;i++){
			min.append(arr[i]);
		}
		return min.toString();
	}
	public static String max(int m,int n){
		int[] arr = new int[m];
		arr[0] = 1;
		int sum = 1;
		int j = 0;
		for(int i = 1;i <= 9 * m + 10;i++){
			if(sum != n){
				if(arr[j] == 9){
					j++;
				}else{
					arr[j]++;
					sum++;
				}
			}
			else{
				break;
			}
		}
		StringBuilder min = new StringBuilder("");
		for(int i = 0;i < arr.length;i++){
			min.append(arr[i]);
		}
		return min.toString();
	}
    public static int KMPSearch(String txt,String pat){
		int m = pat.length();
		int n = txt.length();
		int lps[] = new int[m];
		int j = 0;
		int count = 0;
		PrefixTable(pat,m,lps);
		int i = 0;
		while (i < n)
	        {
	            if (pat.charAt(j) == txt.charAt(i))
	            {
	                j++;
	                i++;
	            }
	            if (j == m)
	            {
	            	count++;
	                j = lps[j-1];
	            }
	            else if (i < n && pat.charAt(j) != txt.charAt(i))
	            {
	                if (j != 0)
	                    j = lps[j-1];
	                else
	                    i = i+1;
	            }
	        }
		return count;
	}
	public static void PrefixTable(String pat,int m,int[] lps){
		int len = 0;
		int i = 1;
		lps[0] = 0;
		while(i < m){
			if(pat.charAt(i) == pat.charAt(len)){
				lps[i] = len + 1;
				i++;
				len++;
			}else if(len > 0){
				len = lps[len - 1];
			}else{
				lps[i] = 0;
				i++;
			}
		}
	}
    public int digit(int x){
    	int temp = x;
    	int count = 0;
    	while(temp != 0){
    		count++;
    		temp = temp/10;
    	}
    	return count;
    }
    public int sum(int x){
    	int temp = x;
    	int count = 0;
    	while(temp != 0){
    		count += temp % 10;
    		temp = temp/10;
    	}
    	return count;
    }
    public int product(int x){
    	int temp = x;
    	int count = 1;
    	while(temp != 0){
    		count*=temp % 10;
    		temp = temp/10;
    	}
    	return count;
    }
    public boolean isValid2(int x){
    	int temp = x;
    	while(temp != 0){
    		if(temp % 10 == 0){
    			return false;
    		}
    		temp = temp/10;
    	}
    	return true;
    }
    public boolean isValid(int x){
    	if(!isValid2(x)){
    		return false;
    	}else{
    		if(product(x) <= sum(x)){
    			return true;
    		}
    		return false;
    	}
    }
}