#include <bits/stdc++.h>
using namespace std;
const int maxn = 20 + 5;
map<long long, int> m;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    char a[maxn], s[maxn];
    cin >> a >> s;
    int len = strlen(s);
    int p = 1;
    long long ans = 0;
    for (int i = len - 1; i >= 0; i--) {
      if ((s[i] - '0') % 2) ans += p;
      p *= 2;
    }
    if (a[0] == '+') {
      m[ans]++;
    } else if (a[0] == '-') {
      m[ans]--;
    } else {
      printf("%d\n", m[ans]);
    }
  }
  return 0;
}
