#include <bits/stdc++.h>
using namespace std;
const int mod = 7 + (int)1e9;
long long process(string s) {
  for (int i = 0; i < s.size(); i++) s[i] = (s[i] - '0') % 2 + '0';
  return stoll(s);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  char c;
  map<long long, int> m;
  cin >> n;
  while (n--) {
    string a;
    cin >> c >> a;
    if (c == '+') {
      m[process(a)]++;
    } else if (c == '-') {
      m[process(a)]--;
    } else if (c == '?') {
      cout << m[stoll(a)] << endl;
    }
  }
  return 0;
}
