#include <bits/stdc++.h>
using namespace std;
map<string, int> mymap;
int t;
long long number;
int main() {
  cin >> t;
  while (t--) {
    char ch;
    cin >> ch;
    if (ch == '+') {
      cin >> number;
      string s;
      s.clear();
      while (number > 0) {
        if (number % 2 == 0) {
          s += '0';
        } else {
          s += '1';
        }
        number /= 10;
      }
      if (mymap.count(s) == 0) {
        mymap[s] = 1;
      } else {
        ++mymap[s];
      }
    }
    if (ch == '-') {
      cin >> number;
      string s;
      s.clear();
      while (number > 0) {
        if (number % 2 == 0) {
          s += '0';
        } else {
          s += '1';
        }
        number /= 10;
      }
      if (mymap[s] == 1) {
        mymap[s] = 0;
      } else {
        --mymap[s];
      }
    }
    if (ch == '?') {
      string s;
      s.clear();
      cin >> s;
      while (s[0] == '0') {
        s.erase(s.begin() + 0);
      }
      reverse(s.begin(), s.end());
      int ans = 0;
      while (s.size() <= 18) {
        if (mymap.count(s) > 0) {
          ans += mymap[s];
        }
        s += '0';
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
