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.IOException;

import java.util.function.BiFunction;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.*;

/**
 * https://codeforces.com/problemset/problem/713/A #datastructures
 * 
 * Use trie data structure to store key-value pairs with keys as numbers
 * (encoded as 10 strings according to given rule) and values as number of
 * occurrences of said key. For each query, aggregate (sum) all values on path
 * to given query key node.
 * 
 * Time complexity: O(t), Memory complexity: O(t)
 */
public class SonyaAndQueries {

	private static String transform(String arg) {
		StringBuilder s = new StringBuilder();
		for (int i = 0; i < (18 - arg.length()); ++i)
			s.append('0');
		for (int i = 0; i < arg.length(); ++i)
			s.append((arg.charAt(i) - '0') % 2);
		return s.toString();
	}

	public static void main(String[] args) throws IOException {
		Reader r = new Reader();
		Writer w = new Writer();

		Trie<Long> trie = new Trie<>('0', '1');

		int t = r.nextInt();

		String a, c;
		Long val;
		for (int i = 0; i < t; ++i) {
			c = r.nextString();
			a = transform(r.nextString());

			switch (c) {
			case "+":
				trie.add(a, ((val = trie.get(a)) == null) ? 1L : val + 1L);
				break;
			case "-":
				val = trie.get(a);
				if (val == 1L)
					trie.remove(a);
				else
					trie.add(a, val - 1);
				break;
			case "?":
				val = trie.get(a, (Long x, Long y) -> {
					if (x == null)
						return y;
					else if (y == null)
						return x;
					else
						return x + y;
				});
				w.println((val == null) ? 0L : val);
				break;
			}
		}

		w.close();
	}

}


/**
 * Custom class for fast input that uses BufferedReader and StringTokenizer.
 */
class Reader {
	private BufferedReader br;
	private StringTokenizer st;

	public Reader() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	private String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public int[] nextIntArray(int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; ++i)
			arr[i] = nextInt();
		return arr;
	}

	public ArrayList<Integer> nextIntArrayList(int size) {
		ArrayList<Integer> lst = new ArrayList<>(size);
		for (int i = 0; i < size; ++i)
			lst.add(nextInt());
		return lst;
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public long[] nextLongArray(int size) {
		long[] arr = new long[size];
		for (int i = 0; i < size; ++i)
			arr[i] = nextLong();
		return arr;
	}

	public ArrayList<Long> nextLongArrayList(int size) {
		ArrayList<Long> lst = new ArrayList<>(size);
		for (int i = 0; i < size; ++i)
			lst.add(nextLong());
		return lst;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public double[] nextDoubleArray(int size) {
		double[] arr = new double[size];
		for (int i = 0; i < size; ++i)
			arr[i] = nextDouble();
		return arr;
	}

	public String nextString() {
		return next();
	}

	public String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}


/**
 * Implementation of trie / prefix tree data structure with String keys and
 * arbitrary typed values.
 *
 * @param <T> Type of values held by the trie.
 */
class Trie<T> {

	/**
	 * Representation of a trie node.
	 *
	 * @param <K> Type of values held by the node.
	 */
	private class TrieNode<K> {

		/**
		 * Placeholder for child nodes.
		 */
		public Object[] links;

		/**
		 * Reference to node's parent.
		 */
		public TrieNode<K> parent;

		/**
		 * Number of child nodes.
		 */
		public int numChildren;

		/**
		 * Value held by the node. Null value is reserved to define node with no value.
		 */
		public K value;

		/**
		 * Constructor for trie node. Creates placeholder array for future child nodes
		 * with size equal to length of range of possible key values.
		 * 
		 * @param minValue Minimum possible key value, e.g. '0'.
		 * @param maxValue Maximum possible key value, e.g. '9'.
		 */
		public TrieNode(int minValue, int maxValue) {
			links = new Object[maxValue - minValue + 1];
		}

	}

	/**
	 * Root of the trie.
	 */
	private TrieNode<T> root;

	/**
	 * Minimum possible key value, e.g. 'a'.
	 */
	private int minValue;

	/**
	 * Minimum possible key value, e.g. 'z'.
	 */
	private int maxValue;

	/**
	 * Trie constructor, initializes the root of the trie.
	 * 
	 * @param minValue Minimum possible key value, e.g. '0'.
	 * @param maxValue Maximum possible key value, e.g. '9'.
	 */
	public Trie(int minValue, int maxValue) {
		this.minValue = minValue;
		this.maxValue = maxValue;
		root = new TrieNode<T>(minValue, maxValue);
	}

	/**
	 * Adds new key-value pair to the trie.
	 * 
	 * Time complexity: O(m), Memory complexity: O(m)
	 * 
	 * @param key   String key.
	 * @param value Arbitrary typed value, should not be null.
	 */
	@SuppressWarnings("unchecked")
	public void add(String key, T value) {
		TrieNode<T> node = root;
		int index;
		for (int i = 0; i < key.length(); ++i) {
			index = key.charAt(i) - minValue;
			if (node.links[index] == null) {
				node.links[index] = new TrieNode<T>(minValue, maxValue);
				((TrieNode<T>) node.links[index]).parent = node;
				++node.numChildren;
			}
			node = (TrieNode<T>) node.links[index];
		}
		node.value = value;
	}

	/**
	 * Retrieves value assigned to given key.
	 * 
	 * Time complexity: O(m), Memory complexity: O(1)
	 * 
	 * @param key String key.
	 * @return Value assigned to the key, or null if key not present.
	 */
	public T get(String key) {
		return get(key, (T t1, T t2) -> t2);
	}

	/**
	 * Aggregates values assigned to all nodes on path defined by given string key.
	 * Values are aggregated in order from root to leaf. Note that initial
	 * aggregated value is calculated by aggregating null with value in root node.
	 * 
	 * Time complexity: O(m), Memory complexity: O(1)
	 * 
	 * @param <R>       Type of value returned by aggregation function.
	 * @param key       String key.
	 * @param aggregate Aggregation function defined as agg(T, T) = R
	 * @return Aggregated result.
	 */
	@SuppressWarnings("unchecked")
	public <R> R get(String key, BiFunction<T, T, R> aggregate) {
		TrieNode<T> node = root;
		T value = root.value;
		R result = aggregate.apply(null, value);
		int index;

		for (int i = 0; i < key.length(); ++i) {
			index = key.charAt(i) - minValue;
			if (node.links[index] == null)
				break;
			else {
				node = (TrieNode<T>) node.links[index];
				result = aggregate.apply(value, node.value);
				value = node.value;
			}
		}
		return result;
	}

	/**
	 * Removes key-value pair defined by given key.
	 * 
	 * Time complexity: O(m), Memory complexity: O(1)
	 * 
	 * @param key String key.
	 */
	@SuppressWarnings("unchecked")
	public void remove(String key) {
		TrieNode<T> node = root;
		int index;

		for (int i = 0; i < key.length(); ++i) {
			index = key.charAt(i) - minValue;
			if (node.links[index] == null)
				return;
			node = (TrieNode<T>) node.links[index];
		}

		// Erase value
		node.value = null;

		// Erase unnecessary links
		for (int i = key.length() - 1; i >= 0 && node.numChildren == 0
				&& node.parent != null; node = node.parent, --i) {
			node.parent.links[key.charAt(i) - minValue] = null;
			--node.parent.numChildren;
		}
	}
}


/**
 * Custom class used for fast output.
 */
class Writer {
	private final BufferedWriter bw;

	public Writer() {
		this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
	}

	public void print(Object object) throws IOException {
		bw.append("" + object);
	}

	public void println(Object object) throws IOException {
		print(object);
		bw.append("\n");
	}

	public void close() throws IOException {
		bw.close();
	}

}
