#include <bits/stdc++.h>
using namespace std;
const int N = 110000, mod = 1e9 + 7;
char s[110];
int c[20][1000100];
int jug(long long x) {
  while (x) {
    if (x % 2 == 1) return 0;
    x /= 10;
  }
  return 1;
}
int main() {
  int n;
  long long x;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    if (s[0] != '?') {
      scanf("%I64d", &x);
      int st = 0;
      for (long long i = 0, now = 1; i < 18; i++, now <<= 1) {
        if (x % 2) st |= now;
        x /= 10;
        if (jug(x)) c[i][st] += (s[0] == '+' ? 1 : -1);
      }
    } else {
      scanf("%s", s);
      int len = strlen(s);
      int st = 0;
      for (int i = 0; i < len; i++) st <<= 1, st |= s[i] - '0';
      printf("%d\n", c[len - 1][st]);
    }
  }
}
