#include <bits/stdc++.h>   using namespace std;   int in() {     int n;     scanf( %d , &n);     return n;   }   long long Lin() {     long long n;     scanf( %lld , &n);     return n;   }   double Din() {     double n;     scanf( %lf , &n);     return n;   }   const long long inf = (long long)1e17;   const long long mod = (long long)1e9 + 7;   const int N = 5e5 + 5;   struct trie {     trie* node[2];     int cnt;     trie() {       node[0] = node[1] = NULL;       cnt = 0;     }   };   void add(trie* root, long long x, bool ck) {     for (int i = 1; i <= 18; i++) {       int p = (x % 2 == 1);       x /= 10;       if (root->node[p] == NULL) root->node[p] = new trie;       root = root->node[p];     }     ck ? root->cnt++ : root->cnt--;   }   int query(trie* root, string s) {     reverse(s.begin(), s.end());     while (s.size() < 18) s.push_back( 0 );     for (int i = 0; i < 18; i++) {       int p = s[i] -  0 ;       if (root->node[p] == NULL) return 0;       root = root->node[p];     }     return root->cnt;   }   int solve() {     int q = in();     trie* root = new trie;     while (q--) {       string ck;       long long x;       cin >> ck;       if (ck ==  + ) {         x = Lin();         add(root, x, true);       } else if (ck ==  - ) {         x = Lin();         add(root, x, false);       } else {         string s;         cin >> s;         printf( %d n , query(root, s));       }     }     return 0;   }   int main() {     int test = 1, tc = 0;     while (test--) {       solve();     }     return 0;   }   