#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, n, m, k, cnt = 0, ans = 0, t = 1;
  cin >> n;
  map<string, long long> mm;
  for (i = 0; i < n; i++) {
    char c;
    string g;
    cin >> c >> g;
    string s = "";
    for (j = 0; j < g.length(); j++) s += (char)(((g[j] - '0') % 2) + '0');
    if (c == '+')
      mm[s]++;
    else if (c == '-')
      mm[s]--;
    else {
      ans = 0;
      cnt = 0;
      for (j = 0; j < s.length(); j++) {
        if (s[j] != '0') break;
        cnt++;
      }
      s = s.substr(cnt, s.length() - cnt);
      while (s.length() <= 19) {
        if (mm.count(s)) ans += mm[s];
        s = '0' + s;
      }
      cout << ans << '\n';
    }
  }
  return 0;
}
