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