#include <bits/stdc++.h>
using namespace std;
int n;
unordered_map<string, unsigned long long> mymap;
string pad(string arg) {
  while (arg.size() < 18) {
    arg = "0" + arg;
  }
  return arg;
}
string getstr(unsigned long long arg) {
  string s = to_string(arg);
  string res = "";
  for (int i = 0; i < s.size(); i++) {
    res += ((s[i] - '0') % 2) ? '1' : '0';
  }
  return pad(res);
}
int main(int argc, char** argv) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "+") {
      unsigned long long t = 0;
      cin >> t;
      mymap[getstr(t)]++;
    } else if (s == "-") {
      unsigned long long t = 0;
      cin >> t;
      mymap[getstr(t)]--;
    } else if (s == "?") {
      string t = "";
      cin >> t;
      cout << mymap[pad(t)] << "\n";
    }
  }
  return 0;
}
