#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int t, x;
string s;
char ch;
string transform(string x) {
  string s = "";
  for (char ch : x)
    if ((ch - '0') % 2)
      s += "1";
    else
      s += "0";
  while (s.size() < 20) s = "0" + s;
  return s;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> ch >> s;
    s = transform(s);
    if (ch == '?') {
      cout << mp[s] << endl;
    } else {
      if (ch == '+') mp[s]++;
      if (ch == '-') mp[s]--;
    }
  }
  return 0;
}
