#include <bits/stdc++.h>
using namespace std;
string buq(string x) {
  int len = x.size();
  string ans = "";
  for (int i = 0; i < 20 - len; i++) {
    ans += '0';
  }
  ans += x;
  return ans;
}
map<string, long long> mp;
void insert(long long x) {
  string tmp = "";
  while (x) {
    if (x % 2 == 0) {
      tmp += '0';
    } else
      tmp += '1';
    x /= 10;
  }
  reverse(tmp.begin(), tmp.end());
  mp[buq(tmp)]++;
}
void sub(long long x) {
  string tmp = "";
  while (x) {
    if (x % 2 == 0) {
      tmp += '0';
    } else
      tmp += '1';
    x /= 10;
  }
  reverse(tmp.begin(), tmp.end());
  mp[buq(tmp)]--;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    char op;
    cin >> op;
    long long in;
    string in1;
    if (op == '+') {
      cin >> in;
      insert(in);
    } else if (op == '-') {
      cin >> in;
      sub(in);
    } else if (op == '?') {
      cin >> in1;
      cout << mp[buq(in1)] << endl;
    }
  }
  return 0;
}
