#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main(void) {
  int t;
  scanf("%d", &t);
  multiset<string> ms;
  map<string, int> map;
  while (t--) {
    char x;
    long long int a;
    scanf(" %c %lld", &x, &a);
    if (x == '+') {
      string arr = "";
      while (a) {
        arr += ((a % 10) % 2) + '0';
        a /= 10;
      }
      reverse(arr.begin(), arr.end());
      string final = "";
      int xx = 18 - arr.size();
      while (xx--) final += '0';
      for (auto i : arr) final += i;
      auto it = map.find(final);
      if (it != map.end()) {
        map[final]++;
      } else {
        map.insert(make_pair(final, 1));
      }
    } else if (x == '-') {
      string arr = "";
      while (a) {
        arr += ((a % 10) % 2) + '0';
        a /= 10;
      }
      reverse(arr.begin(), arr.end());
      string final = "";
      int xx = 18 - arr.size();
      while (xx--) final += '0';
      for (auto i : arr) final += i;
      map[final]--;
    } else {
      string arr = "";
      while (a) {
        arr += ((a % 10) % 2) + '0';
        a /= 10;
      }
      reverse(arr.begin(), arr.end());
      string final = "";
      int xx = 18 - arr.size();
      while (xx--) final += '0';
      for (auto i : arr) final += i;
      auto it = map.find(final);
      if (it != map.end()) {
        int ans = map[final];
        printf("%d\n", ans);
      } else {
        printf("0\n");
      }
    }
  }
  return (0);
}
