#include <bits/stdc++.h>
long cnt[270000] = {};
long f(long long x) {
  long ans = 0;
  for (long i = 0; x != 0; x /= 10, i++) {
    long t = x % 10;
    if (t & 1) ans = ans | (1 << i);
  }
  return ans;
}
int main() {
  long t;
  scanf("%ld", &t);
  while (t--) {
    char ord[5];
    long long arg;
    scanf("%s%I64d", ord, &arg);
    if (ord[0] == '+')
      cnt[f(arg)]++;
    else if (ord[0] == '-')
      cnt[f(arg)]--;
    else
      printf("%ld\n", cnt[f(arg)]);
  }
  return 0;
}
