#include <bits/stdc++.h>
int calc(long long x) {
  int y = 0;
  for (int i = 1; i <= 18; i++, x /= 10) y = y << 1 | (x & 1);
  return y;
}
int cnt[1 << 20];
int main() {
  int t;
  char op[10];
  long long x;
  for (scanf("%d", &t); t; t--) {
    scanf("%s %lld", op, &x);
    x = calc(x);
    if (*op == '+')
      cnt[x]++;
    else if (*op == '-')
      cnt[x]--;
    else
      printf("%d\n", cnt[x]);
  }
}
