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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Star Orpheus
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskС solver = new TaskС();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskС {
        Trie root = new Trie();

        void add(final String s) {
            Trie cur = root;

            for (int i = 0; i < s.length(); i++) {
                if ((s.charAt(i) & 1) == 0) {
                    if (cur.l == null)
                        cur.l = new Trie();
                    cur = cur.l;
                } else {
                    if (cur.r == null)
                        cur.r = new Trie();
                    cur = cur.r;
                }
            }
            cur.cnt++;
        }

        void rem(final String s) {
            Trie cur = root;

            for (int i = 0; i < s.length(); i++) {
                if ((s.charAt(i) & 1) == 0) {
                    assert cur.l != null;
                    cur = cur.l;
                } else {
                    assert cur.r != null;
                    cur = cur.r;
                }
            }
            cur.cnt--;
        }

        int query(final String pattern) {
            Trie cur = root;
            int res = 0;
//        System.err.println("#" + fln + "#");

            for (int i = 0; i < pattern.length(); i++) {
                if ((pattern.charAt(i) & 1) == 0) {
                    if (cur.l == null)
                        return 0;

                    cur = cur.l;
                } else {
                    if (cur.r == null)
                        return 0;

                    cur = cur.r;
                }
            }
            res += cur.cnt;
            while (cur.l != null) {
                cur = cur.l;
                res += cur.cnt;
            }

            return res;
        }

        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int t = in.nextInt();

            for (; t > 0; t--) {
                String type = in.next();
                String alpha = in.next();
                if (type.equalsIgnoreCase("+")) {
                    add(new StringBuilder(alpha).reverse().toString());
                } else if (type.equalsIgnoreCase("-")) {
                    rem(new StringBuilder(alpha).reverse().toString());
                } else if (type.equalsIgnoreCase("?")) {
                    StringBuilder bld = new StringBuilder(alpha).reverse();
                    int fln = bld.length();
                    for (int i = bld.length() - 1; i >= 0 && bld.charAt(i) == '0'; i--)
                        fln = i;
//                System.err.println(bld.substring(0, fln));
                    out.println(query(bld.substring(0, fln)));
                } else {
                    System.err.println("`" + type + "`");
                }
            }
        }

        class Trie {
            public Trie l = null;
            public Trie r = null;
            public int cnt = 0;

            Trie() {
            }

        }

    }

    static class FastScanner {
        final static int BUFFER_SIZE = 65536;
        BufferedReader br;
        char[] buf = new char[BUFFER_SIZE];
        int len = 0;
        int it = 0;
        boolean end = false;

        boolean delim(char c) {
            return c == ' ' || c == '\n' || c == '\r';
        }

        void fillBuffer() {
            try {
                len = br.read(buf);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void ensureBuffer() {
            if (it == len) {
                it = 0;
                fillBuffer();
                if (len == -1) end = true;
            }
        }

        void moveNext() {
            while (!end) {
                ensureBuffer();
                if (!delim(buf[it])) return;
                while (it < len && delim(buf[it])) it++;
            }
        }

        public String next() {
            moveNext();
            StringBuilder sb = new StringBuilder();
            while (!end) {
                int l = it;
                while (++it < len && !delim(buf[it])) ;
                sb.append(buf, l, it - l);
                ensureBuffer();
                if (delim(buf[it])) break;
            }
            return sb.toString();
        }

        public int nextInt() {
            moveNext();
            if (buf[it] == '-') {
                it++;
                return -nextInt();
            }
            if (buf[it] == '+') {
                it++;
                return nextInt();
            }
            int result = 0;
            while (!end) {
                int l = it;
                while (it < len && !delim(buf[it])) {
                    result = (result * 10) + buf[it] - '0';
                    it++;
                }
                ensureBuffer();
                if (end || delim(buf[it])) break;
            }
            return result;
        }

        public FastScanner(String file) {
            try {
                br = new BufferedReader(new FileReader(file), BUFFER_SIZE);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is), BUFFER_SIZE);
        }

    }
}

