#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
long long change(long long n) {
  long long ans = 0, t = 1;
  while (n) {
    ans += (n % 10 % 2) * t;
    t *= 10;
    n /= 10;
  }
  return ans;
}
int main() {
  int n, i;
  long long t;
  char ch[5];
  while (scanf("%d", &n) != EOF) {
    mp.clear();
    while (n--) {
      scanf("%s%lld", ch, &t);
      t = change(t);
      if (ch[0] == '+')
        mp[t]++;
      else if (ch[0] == '-')
        mp[t]--;
      else if (ch[0] == '?')
        printf("%d\n", mp[t]);
    }
  }
  return 0;
}
