#include <bits/stdc++.h>
using namespace std;
long long num_to_sig(long long x) {
  vector<int> v;
  while (x > 0) {
    v.push_back((x % 10) % 2);
    x /= 10;
  }
  int n = v.size();
  long long ret = 0;
  for (int i = n - 1; i >= 0; i--) {
    ret *= 10;
    ret += v[i];
  }
  return ret;
}
int main() {
  int Q;
  scanf("%d", &Q);
  map<long long, int> cnt;
  while (Q--) {
    char c;
    scanf(" %c", &c);
    long long x;
    if (c == '+') {
      scanf("%lld", &x);
      cnt[num_to_sig(x)]++;
    } else if (c == '-') {
      scanf("%lld", &x);
      cnt[num_to_sig(x)]--;
    } else {
      scanf("%lld", &x);
      printf("%d\n", cnt[num_to_sig(x)]);
    }
  }
  return 0;
}
