#include <bits/stdc++.h>
using namespace std;
long long tmp;
map<long long, long long> mp;
void add(long long tmp) {
  long long ans = 0;
  int cnt = 0;
  while (tmp) {
    if (tmp % 10 % 2 == 1) {
      ans |= (1 << cnt);
    }
    tmp /= 10;
    cnt++;
  }
  mp[ans]++;
}
void dele(long long tmp) {
  long long ans = 0;
  int cnt = 0;
  while (tmp) {
    if (tmp % 10 % 2 == 1) {
      ans |= (1 << cnt);
    }
    tmp /= 10;
    cnt++;
  }
  mp[ans]--;
}
long long trans(long long tmp) {
  long long ans = 0;
  int cnt = 0;
  while (tmp) {
    if (tmp % 10 % 2 == 1) {
      ans |= (1 << cnt);
    }
    tmp /= 10;
    cnt++;
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) {
    char op[4];
    scanf("%s", op);
    long long tmp;
    if (op[0] == '+') {
      scanf("%lld", &tmp);
      add(tmp);
    } else if (op[0] == '-') {
      scanf("%lld", &tmp);
      dele(tmp);
    } else if (op[0] == '?') {
      scanf("%lld", &tmp);
      printf("%lld\n", mp[trans(tmp)]);
    }
  }
  return 0;
}
