#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long q;
  cin >> q;
  map<string, long long> mp;
  for (long long i = 1; i <= q; i++) {
    char c;
    cin >> c;
    string s;
    cin >> s;
    string v;
    bool start = 0;
    for (auto x : s) {
      if ((x - '0') % 2) {
        start = 1;
      }
      if (start) {
        v.push_back((x - '0') % 2);
      }
    }
    if (c == '+') {
      mp[v] += 1;
    }
    if (c == '-') {
      mp[v] -= 1;
    }
    if (c == '?') {
      cout << mp[v] << endl;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
