#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...);
}
template <class T, class T2>
T _f_pow(T a, T2 b) {
  T res = 1LL;
  while (b > 0) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return (res);
}
template <class T>
T gcd(T a, T b) {
  while (a && b)
    if (a > b)
      (a %= b);
    else
      (b %= a);
  return a + b;
}
template <class T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
int t;
map<long long, long long> fr;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    char op;
    long long num;
    cin >> op;
    if (op == '?') {
      long long pat;
      cin >> pat;
      cout << fr[pat] << endl;
      continue;
    }
    cin >> num;
    long long tmp = 0;
    string eo = "";
    while (num > 0) {
      int digit = num % 10LL;
      digit &= 1;
      string dig = "";
      dig += (digit + '0');
      eo = dig + eo;
      num /= 10LL;
    }
    tmp = stoll(eo);
    if (op == '-') {
      fr[tmp]--;
      continue;
    }
    fr[tmp]++;
  }
  return 0;
}
