#include <bits/stdc++.h>
using namespace std;
map<string, int> mapa;
string transform(string &a) {
  string b = "";
  for (int i = 0; i < a.size(); i++) {
    if ((int)(a[i] - '0') % 2 == 0)
      b += '0';
    else
      b += '1';
  }
  int j = 0;
  while (b[j] == '0') j++;
  b = b.substr(j, b.size());
  return b;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    string a, b;
    cin >> a >> b;
    if (a == "+") {
      mapa[transform(b)]++;
    } else if (a == "-") {
      mapa[transform(b)]--;
    } else
      cout << mapa[transform(b)] << endl;
  }
  return 0;
}
