#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> ss;
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    string t, s;
    cin >> t >> s;
    while ((int(s.size())) < 18) s = '0' + s;
    for (int i = 0; i < 18; ++i)
      if ((s[i] - '0') % 2 == 0)
        s[i] = '0';
      else
        s[i] = '1';
    if (t == "+")
      ++ss[s];
    else if (t == "-")
      --ss[s];
    else
      cout << ss[s] << "\n";
  }
  return 0;
}
