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

/**
 * Created by student on 13/9/16.
 */
public class TaskC
{
    public static void main(String[] args) throws IOException
    {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);

        Solver solver = new Solver(in, out);
        solver.solve();

        out.flush();

        in.close();
        out.close();
    }

    static class Solver
    {
        int t;
        Node root;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        OutputWriter out;

        void solve() throws IOException
        {
            String[] tok = in.readLine().split(" ");
            t = Integer.parseInt(tok[0]);
            Map<String, Integer> map = new HashMap<>();
            String z = "00000000000000000000";

            while (t-- > 0)
            {
                String line = in.readLine();

                if (line.charAt(0) == '+')
                {
                    long x = Long.parseLong(line.substring(2, line.length()));
                    String s = "" + x;
                    s = z.substring(0, 18 - s.length()) + s;
                    s = convert(new StringBuilder(s));

                    Integer count = map.get(s);

                    if (count == null)
                        map.put(s, 1);
                    else
                        map.put(s, count + 1);
                }
                else if (line.charAt(0) == '-')
                {
                    long x = Long.parseLong(line.substring(2, line.length()));
                    String s = "" + x;
                    s = z.substring(0, 18 - s.length()) + s;
                    s = convert(new StringBuilder(s));

                    Integer count = map.get(s);

                    if (count == 1)
                        map.remove(s);
                    else
                        map.put(s, count - 1);
                }
                else
                {
                    long x = Long.parseLong(line.substring(2, line.length()));
                    String s = "" + x;
                    s = z.substring(0, 18 - s.length()) + s;
                    s = convert(new StringBuilder(s));

                    Integer count = map.get(s);

                    if (count == null)
                        out.println(0);
                    else
                        out.println(count);
                }
            }
        }

        String convert(StringBuilder s)
        {
            int len = s.length();

            for (int i = 0; i < len; i++)
            {
                int ch = s.charAt(i);
                int n = ch - '0';

                if (n % 2 == 0)
                    s.setCharAt(i, '0');
                else
                    s.setCharAt(i, '1');
            }

            return s.toString();
        }

        Node insert(Node node, String word, int index)
        {
            int pos = word.charAt(index) - '0';
            Node temp = node.next[pos];

            if (temp == null)
                temp = new Node();

            if (index == 17)
                temp.isWord++;
            else
                temp = insert(temp, word, index + 1);

            temp.exists++;
            node.next[pos] = temp;

            return node;
        }

        int count(Node node, String word, int index)
        {
            int pos = word.charAt(index) - '0';
            Node temp = node.next[pos];

            if (index == 17)
            {
                if (temp != null)
                    return temp.exists;

                return 0;
            }

            if (temp != null)
                return count(temp, word, index + 1);

            return 0;
        }

        long maxXor(Node node, String word, int index)
        {
            int pos = word.charAt(index) - '0';
            int req = pos == 1 ? 0 : 1;
            Node temp = node.next[pos];
            Node reqTemp = node.next[req];

            if (index == 31)
            {
                if (reqTemp != null && reqTemp.isWord > 0)
                    return 1;

                return 0;
            }

            if (reqTemp != null)
            {
                if (reqTemp.exists > 0)
                    return (1 << (31 - index)) + maxXor(reqTemp, word, index + 1);

                if (temp != null)
                    return Math.max(maxXor(temp, word, index + 1), maxXor(reqTemp, word, index + 1));

                return maxXor(reqTemp, word, index + 1);

            }

            if (temp != null)
                return maxXor(temp, word, index + 1);

            return 0;
        }

        boolean delete(Node node, String word, int index)
        {
            int pos = word.charAt(index) - '0';
            Node temp = node.next[pos];

            if (temp == null)
                return false;

            if (index == 17)
            {
                if (temp.isWord > 0)
                {
                    temp.isWord--;

                    return true;
                }

                return false;
            }

            boolean deleted = delete(temp, word, index + 1);

            if (deleted)
            {
                temp.exists--;

                return true;
            }

            return false;
        }

        class Node
        {
            int isWord, exists;
            Node[] next;

            public Node()
            {
                next = new Node[2];
            }

        }

        public Solver(InputReader in, OutputWriter out)
        {
            this.out = out;
        }

    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(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 & 15;

                c = read();
            } while (!isSpaceChar(c));

            return res * sgn;
        }

        public int[] nextIntArray(int arraySize)
        {
            int array[] = new int[arraySize];

            for (int i = 0; i < arraySize; i++)
                array[i] = nextInt();

            return array;
        }

        public long nextLong()
        {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sign = 1;

            if (c == '-')
            {
                sign = -1;

                c = read();
            }

            long result = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                result *= 10;
                result += c & 15;

                c = read();
            } while (!isSpaceChar(c));

            return result * sign;
        }

        public long[] nextLongArray(int arraySize)
        {
            long array[] = new long[arraySize];

            for (int i = 0; i < arraySize; i++)
                array[i] = nextLong();

            return array;
        }

        public float nextFloat() // problematic
        {
            float result, div;
            byte c;

            result = 0;
            div = 1;
            c = (byte) read();

            while (c <= ' ')
                c = (byte) read();

            boolean isNegative = (c == '-');

            if (isNegative)
                c = (byte) read();

            do
            {
                result = result * 10 + c - '0';
            } while ((c = (byte) read()) >= '0' && c <= '9');

            if (c == '.')
                while ((c = (byte) read()) >= '0' && c <= '9')
                    result += (c - '0') / (div *= 10);

            if (isNegative)
                return -result;

            return result;
        }

        public double nextDouble() // not completely accurate
        {
            double ret = 0, div = 1;
            byte c = (byte) read();

            while (c <= ' ')
                c = (byte) read();

            boolean neg = (c == '-');

            if (neg)
                c = (byte) read();

            do
            {
                ret = ret * 10 + c - '0';
            } while ((c = (byte) read()) >= '0' && c <= '9');

            if (c == '.')
                while ((c = (byte) read()) >= '0' && c <= '9')
                    ret += (c - '0') / (div *= 10);

            if (neg)
                return -ret;

            return ret;
        }

        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 boolean isSpaceChar(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String nextLine()
        {
            int c = read();

            StringBuilder result = new StringBuilder();

            do
            {
                result.appendCodePoint(c);

                c = read();
            } while (!isNewLine(c));

            return result.toString();
        }

        public boolean isNewLine(int c)
        {
            return c == '\n';
        }

        public void close()
        {
            try
            {
                stream.close();
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }

    }

    static class OutputWriter
    {
        private PrintWriter writer;

        public OutputWriter(OutputStream stream)
        {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
                    stream)));
        }

        public OutputWriter(Writer writer)
        {
            this.writer = new PrintWriter(writer);
        }

        public void println(int x)
        {
            writer.println(x);
        }

        public void print(int x)
        {
            writer.print(x);
        }

        public void println(char x)
        {
            writer.println(x);
        }

        public void print(char x)
        {
            writer.print(x);
        }

        public void println(int array[], int size)
        {
            for (int i = 0; i < size; i++)
                println(array[i]);
        }

        public void print(int array[], int size)
        {
            for (int i = 0; i < size; i++)
                print(array[i] + " ");
        }

        public void println(long x)
        {
            writer.println(x);
        }

        public void print(long x)
        {
            writer.print(x);
        }

        public void println(long array[], int size)
        {
            for (int i = 0; i < size; i++)
                println(array[i]);
        }

        public void print(long array[], int size)
        {
            for (int i = 0; i < size; i++)
                print(array[i]);
        }

        public void println(float num)
        {
            writer.println(num);
        }

        public void print(float num)
        {
            writer.print(num);
        }

        public void println(double num)
        {
            writer.println(num);
        }

        public void print(double num)
        {
            writer.print(num);
        }

        public void println(String s)
        {
            writer.println(s);
        }

        public void print(String s)
        {
            writer.print(s);
        }

        public void println()
        {
            writer.println();
        }

        public void printSpace()
        {
            writer.print(" ");
        }

        public void printf(String format, Object args)
        {
            writer.printf(format, args);
        }

        public void flush()
        {
            writer.flush();
        }

        public void close()
        {
            writer.close();
        }

    }

    static class CMath
    {
        static long power(long number, long power)
        {
            if (number == 1 || number == 0 || power == 0)
                return 1;

            if (power == 1)
                return number;

            if (power % 2 == 0)
                return power(number * number, power / 2);
            else
                return power(number * number, power / 2) * number;
        }

        static long modPower(long number, long power, long mod)
        {
            if (number == 1 || number == 0 || power == 0)
                return 1;

            number = mod(number, mod);

            if (power == 1)
                return number;

            long square = mod(number * number, mod);

            if (power % 2 == 0)
                return modPower(square, power / 2, mod);
            else
                return mod(modPower(square, power / 2, mod) * number, mod);
        }

        static long moduloInverse(long number, long mod)
        {
            return modPower(number, mod - 2, mod);
        }

        static long mod(long number, long mod)
        {
            return number - (number / mod) * mod;
        }

        static int gcd(int a, int b)
        {
            if (b == 0)
                return a;
            else
                return gcd(b, a % b);
        }

    }

}
