#include <bits/stdc++.h>
using namespace std;
string s;
map<string, int> M;
char op;
int main() {
  int T;
  cin >> T;
  getchar();
  while (T--) {
    op = getchar();
    cin >> s;
    getchar();
    if (op == '?') {
      while (s.length() > 1 && s[0] == '0') s.erase(s.begin());
      cout << M[s] << endl;
    } else if (op == '+') {
      int l = s.length();
      for (int i = 0; i < l; i++) s[i] = (s[i] - '0') % 2 + '0';
      while (s.length() > 1 && s[0] == '0') s.erase(s.begin());
      M[s]++;
    } else if (op == '-') {
      int l = s.length();
      for (int i = 0; i < l; i++) s[i] = (s[i] - '0') % 2 + '0';
      while (s.length() > 1 && s[0] == '0') s.erase(s.begin());
      M[s]--;
    }
  }
}
