#include <bits/stdc++.h>
class TaskA {
 public:
  void solve(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    std::vector<int> arr((1 << 19));
    char query;
    std::string s;
    long long index;
    for (int i = 0; i < n; ++i) {
      in >> query;
      in >> s;
      if (query == '+' || query == '-') {
        index = 0;
        for (int j = 0; j < (int)s.length(); ++j) {
          index <<= 1;
          index += (s[j] - '0') % 2;
        }
        if (query == '+')
          arr[index]++;
        else
          arr[index]--;
      } else {
        index = 0;
        for (int j = 0; j < (int)s.length(); ++j) {
          index <<= 1;
          index += (s[j] == '1');
        }
        out << arr[index] << "\n";
      }
    }
  }
};
int main() {
  TaskA solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
