#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  unsigned long long n;
  cin >> n;
  map<string, unsigned long long> m;
  unsigned long long x;
  while (n--) {
    char cm;
    cin >> cm;
    if (cm == '+' || cm == '-') {
      cin >> x;
      unsigned long long new_x = 0;
      stringstream ss;
      ss << x;
      string s2 = ss.str();
      string s;
      for (int i = 0; i < s2.size(); ++i) {
        char ch = (s2[i] - '0') % 2 ? '1' : '0';
        if (ch == '1' || s.size() > 0) {
          s.push_back(ch);
        }
      }
      if (s.size() == 0) {
        s = "0";
      }
      if (cm == '+') {
        m[s]++;
      } else {
        m[s]--;
      }
    } else {
      cin >> x;
      stringstream ss;
      ss << x;
      string s = ss.str();
      cout << m[s] << endl;
    }
  }
  return 0;
}
