#include <bits/stdc++.h>
using namespace std;
clock_t t1 = clock();
unordered_map<long long, long long> counts;
long long getBin(string n) {
  long long ans = 0;
  char temp;
  long long j = ((int)(n).size());
  long long i;
  for (i = (0); i != (j - 1) + 1 - 2 * ((0) > (j - 1));
       i += 1 - 2 * ((0) > (j - 1))) {
    temp = n[i];
    ans = (ans * 10) + ((long long)(temp) % 2 ? 1 : 0);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  long long t;
  char x;
  string num;
  cin >> t;
  while (t--) {
    cin >> x >> num;
    if (x == '?') cout << counts[getBin(num)] << "\n";
    if (x == '+') counts[getBin(num)]++;
    if (x == '-') counts[getBin(num)]--;
  }
  return 0;
}
