#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
int main(int argc, char *argv[]) {
  int T;
  scanf("%d\n", &T);
  map<ll, int> stronzi;
  while (T--) {
    char operation;
    ll dioi, dio = 0;
    scanf("%c %llu\n", &operation, &dioi);
    int p = 1;
    for (int i = 0; i < 18; i++, p *= 10) {
      dio += (dioi % 2) * p;
      dioi /= 10;
    }
    if (operation == '+') {
      stronzi[dio]++;
    } else if (operation == '-') {
      stronzi[dio]--;
    } else if (operation == '?') {
      cout << stronzi[dio] << endl;
    }
  }
  return 0;
}
