#include <bits/stdc++.h>
using namespace std;
const int D = 20;
map<string, int> ans;
map<int64_t, int> cnt;
string pattern(int64_t a) {
  string str = "";
  int d = 0;
  while (a > 0) {
    d = a % 10;
    str += (d % 2 == 0 ? '0' : '1');
    a /= 10;
  }
  reverse(str.begin(), str.end());
  str = string(D - str.size(), '0') + str;
  return str;
}
void add(int64_t a) {
  cnt[a]++;
  string p = pattern(a);
  ans[p]++;
}
void remove(int64_t a) {
  cnt[a]--;
  string p = pattern(a);
  ans[p]--;
}
int main() {
  int t;
  int64_t a;
  char op;
  string pat;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> op;
    switch (op) {
      case '+':
        cin >> a;
        add(a);
        break;
      case '-':
        cin >> a;
        remove(a);
        break;
      case '?':
        cin >> pat;
        pat = string(D - pat.size(), '0') + pat;
        cout << ans[pat] << "\n";
        break;
    }
  }
  return 0;
}
