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.awt.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
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.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.*;


 
 
public class ck {

	private static InputStream stream;
	private static PrintWriter pw;
	
	
	
//	static int a;
//	static int b;
//	static int f = 0;
//	static int n;
//	static int m;
//	static char[][] arr;
	

	
//	static int[][] dir = {{-1,0},{0,1},{1,0},{0,-1}};

//	static int visited[][];
	
	
//	static ArrayList<Integer> ans;

//	static int arr[][];
//	static int arr[];
//	static char[][] arr;
//	static int[][] visited;
//  static int c;
//	static int d[];
//	static int arr[][];
//	static ArrayList<Integer> arr[];
	static ArrayList<Integer> comp[];
	
	//static int c;
	static int parent[];
	static int nodes;
	static long ans = 0;
	static long a;
	static long d;
	static int n;
	
	public static void main(String[] args) throws NumberFormatException, IOException{
		//InputReader(System.in);
		//pw = new PrintWriter(System.out);
		
		Scanner in = new Scanner(System.in);
		
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
	
		int n = in.nextInt();
		in.nextLine();
		
		HashMap<String,ArrayList<String>> map = new HashMap();
		
		for(int i = 0;i<n;i++){
			char c = in.next().charAt(0);
			
			if(c == '+'){
				String s = in.next();
				String t = "";
				
				int k = s.length();
				for(int j = 0;j<18-k;j++){
					s = '0'+s;
				}
				
				for(int j = 0;j<18;j++){
					if(s.charAt(j)%2 == 0){
						t += '0';
					}else{
						t += '1';
					}
				}
				//System.out.println(s);
				if(map.containsKey(t)){
					ArrayList<String> temp = map.get(t);
					temp.add(s);
					map.put(t, temp);
				}else{
					ArrayList<String> temp = new ArrayList();
					temp.add(s);
					map.put(t,temp);
				}
				
				
			}else if(c == '-'){
				
				String s = in.next();
				String t = "";
				
				int k = s.length();
				for(int j = 0;j<18-k;j++){
					s = '0'+s;
				}
				
				for(int j = 0;j<18;j++){
					if(s.charAt(j)%2 == 0){
						t += '0';
					}else{
						t += '1';
					}
				}
				//System.out.println(s);
				if(map.containsKey(t)){
					ArrayList<String> temp = map.get(t);
					temp.remove(s);
					map.put(t, temp);
				}else{
					
				}
				
			}else{
				
				String t = in.next();
				
				
				int k = t.length();
				for(int j = 0;j<18-k;j++){
					t = '0'+t;
				}
				
				if(map.containsKey(t)){
					System.out.println(map.get(t).size());
				}else{
					System.out.println(0);
				}
			}
		}
		
		}
	
	
	public static long dfs(int i){
		
		if(i == 1){
			return a;
		}
		
		if(i == 2){
			return a + (long)Math.min(a, d);
		}
		
		if(i%2 == 0){
			
			if((i/2)*a < d){
				return dfs(i/2) + (long)(i/2)*a;
			}else{
				return dfs(i/2) + d;
			}
		}else{
			return (long)Math.min(dfs(i-1),dfs(i+1)) + a;
		}
		
		
	}
public static void ddfs(int n,int m,int i,int j,char arr[][],int visited[][],int dir[][],int store[][],int ans){
		
		if(visited[i][j] == 1){
			return;
		}
		
		
		//System.out.println(i + " " + j + " " + arr[i][j]);
		if(arr[i][j] == '*'){
			ans++;
			return;
		}
		
		visited[i][j] = 1;
		store[i][j] = ans;
		int x = i;
		int y = j;
		
		for(int p = 0;p<4;p++){
			
			i = x + dir[p][0];
			j = y + dir[p][1];
			
			if(i < 0 || i >= n|| j < 0 || j >=m){
				
			}else{
				dfs(n,m,i,j,arr,visited,dir);
			}
			
		}
		
		
	}
	
	
	public static void dfs(int n,int m,int i,int j,char arr[][],int visited[][],int dir[][]){
		
		if(visited[i][j] == 1){
			return;
		}
		
		
		//System.out.println(i + " " + j + " " + arr[i][j]);
		if(arr[i][j] == '*'){
			ans++;
			return;
		}
		
		visited[i][j] = 1;
		int x = i;
		int y = j;
		
		for(int p = 0;p<4;p++){
			
			i = x + dir[p][0];
			j = y + dir[p][1];
			
			if(i < 0 || i >= n|| j < 0 || j >=m){
				
			}else{
				dfs(n,m,i,j,arr,visited,dir);
			}
			
		}
		
		
	}
	
	

//	
//	public static void bfs(int i){
//		
//		Queue<Integer> q=new LinkedList<Integer>();
//    	q.add(i);
//    	
//    	visited[i] = 1;
//    	c++;
//    	nodes++;
//    	while(!q.isEmpty()){
//    		int top=q.poll();
//    		
//    		Iterator<Integer> it= arr[top].listIterator();
//    		while(it.hasNext()){
//    			int next =it.next();
//    			
//    			if(visited[next] == 0){
//    				nodes++;
//    				visited[next] = 1;
//    				q.add(next);
//    			}
//    		
//    		}
//    	}
//		
//	}
	
	
	public static void union(int a,int b){
		a = find(a);
		b = find(b);
		
		parent[a] = b;
		return;
	}
	
	public static int find(int i){
		if(i == parent[i]){
			return i;
		}
		
		parent[i] = find(parent[i]);
		return parent[i];
	}
	
//	public static void dfs(int i){
//		
//		
//		if(visited[i] == 1){
//			return;
//		}
//		
//		visited[i] = 1;
//		con[c].add(i);
//		//System.out.print(i + " ");
//		for(int j = 0;j<arr[i].size();j++){
//			dfs(arr[i].get(j));
//		}
//		
//	}
//	
//	
//	public static void dfss(int i){
//		if(visited[i] == 1){
//			return;
//		}
//		
//		visited[i] = 1;
//		
//		for(int j = 0;j<arr[i].size();j++){
//			dfss(arr[i].get(j));
//		}
//	//	System.out.println(i);
//		stack.push(i);
//	}
//	
//	public static void reverse(){
//		ArrayList[] temp = new ArrayList[n];
//		
//		for(int i = 0;i<n;i++){
//			temp[i] = new ArrayList();
//		}
//		
//		for(int i = 0;i<n;i++){
//			for(int j = 0;j<arr[i].size();j++){
//				temp[arr[i].get(j)].add(i);
//			}
//		}
//		
//		arr = temp;
//		
//	}
//	
//	
	
	
	
	
	
	
	public static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
 
		// This is checked so that we can skip 
		// middle five numbers in below loop
		if (n % 2 == 0 || n % 3 == 0)
			return false;
 
		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;
 
		return true;
	}
	
	
	
	public static void Range(int[] numbers, int target) {
	    if (numbers == null)
	        return;

	    int low = 0, high = numbers.length - 1;
	    // get the start index of target number
	    int startIndex = -1;
	    while (low <= high) {
	        int mid = (high - low) / 2 + low;
	        if (numbers[mid] > target) {
	            high = mid - 1;
	        } else if (numbers[mid] == target) {
	            startIndex = mid;
	            high = mid - 1;
	        } else
	            low = mid + 1;
	    }

	    // get the end index of target number
	    int endIndex = -1;
	    low = 0;
	    high = numbers.length - 1;
	    while (low <= high) {
	        int mid = (high - low) / 2 + low;
	        if (numbers[mid] > target) {
	            high = mid - 1;
	        } else if (numbers[mid] == target) {
	            endIndex = mid;
	            low = mid + 1;
	        } else
	            low = mid + 1;
	    }

	    if (startIndex != -1 && endIndex != -1){
	        for(int i=0; i+startIndex<=endIndex;i++){
	            if(i>0)
	                System.out.print(',');
	            System.out.print(i+startIndex);
	        }
	    }
	}
	
	 // union code starts	
	
	 private static void initialize( int Arr[ ],int size[], int N)
	    {
	        for(int i = 0;i<N;i++)
	        {
	        	Arr[ i ] = i ;
	        	size[ i ] = 1;
	        }
	    }
	 
	 private static int root(int Arr[ ],int i)
	    {
	        while(Arr[ i ] != i)           //chase parent of current element until it reaches root
	        {
	            Arr[ i ] = Arr[ Arr[ i ] ] ; 
	            i = Arr[ i ];
	        }
	        return i;
	    }
	 
	 private static void union(int Arr[ ],int size[ ],int A,int B)
	    {
	        int root_A = root(Arr,A);
	        int root_B = root(Arr,B);
	     
	        if(root_A != root_B){
	        	 if(size[root_A] < size[root_B ])
	 	        {
	        		 Arr[ root_A ] = Arr[root_B];
	        		 size[root_B] += size[root_A];	 	
	 	        }
	 	        else
	 	        {   	
	 	        	Arr[ root_B ] = Arr[root_A];
	 	        	size[root_A] += size[root_B];	 	   
	 	        }	
	        }
	    }
	 
	 private static boolean find(int Arr[],int A,int B)
	    {
	        if( root(Arr,A)==root(Arr,B) )       //if A and B have the same root, it means that they are connected.
	        return true;
	        else
	        return false;
	    }
	 
	 
	 // union code ends
	
	
	 
//	 // Segment tree code begins
//	 
//	 
//	 static void build(int node,int start,int end)
//	 {
//	 if(start==end)
//	 tree[node]=a[start];
//	 else
//	 {
//	 int mid=(start+end)/2;
//	 build(2*node,start,mid);
//	 build(2*node+1,mid+1,end);
//	 if(tree[2*node]<tree[2*node+1])
//	 tree[node]=tree[2*node];
//	 else
//	 tree[node]=tree[2*node+1];
//	 }
//	 }
//	 
//	 
//	 static void update(int node,int start,int end,int idx,int val)
//	 {
//	 if(start==end)
//	 {
//	 a[idx]=val;
//	 tree[node]=val;
//	 }
//	 else
//	 {
//	 int mid=(start+end)/2;
//	 if(idx>=start&&idx<=mid)
//	 update(2*node,start,mid,idx,val);
//	 else
//	 update(2*node+1,mid+1,end,idx,val);
//	 if(tree[2*node]<tree[2*node+1])
//	 tree[node]=tree[2*node];
//	 else
//	 tree[node]=tree[2*node+1];
//	 }
//	 }
//	 
//	 static int query(int node,int start,int end,int l,int r)
//	 {
//	 if(l>end||start>r)
//	 return 100005;
//	 if(l<=start&&r>=end)
//	 return tree[node];
//	 int p1,p2;
//	 int mid=(start+end)/2;
//	 p1=query(2*node,start,mid,l,r);
//	 p2=query(2*node+1,mid+1,end,l,r);
//	 if(p1<p2)
//	 return p1;
//	 else
//	 return p2;
//	 }
//	 
//	 
//	 
//}

}

class Node{
	int a;
	int b;
}


class MyComp2 implements Comparator<Node>{
    
	@Override
	public int compare(Node o1, Node o2) {
		if(o1.a>o2.a){
			return 1;
		}else if(o1.a<o2.a){
			return -1;
		}else{
			if(o1.b>o2.b){
				return 1;
				
			}else{
				return -1;
			}
			
			
		}
		
		
	}
}


class Card implements Comparable<Card>
{
	int a,b;
	public Card(int w,int h)
	{
		this.a=w;
		this.b=h;
		
	}
	public int compareTo(Card that)
	{
		return this.a-that.a;
	}
}
