#include <bits/stdc++.h>
using namespace std;
map<string, int> co;
string get(string x) {
  int i;
  for (i = 0; i < x.size(); i++) {
    x[i] = ((x[i] - '0') % 2 + '0');
  }
  x = string(19 - x.size(), '0') + x;
  return x;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> a >> b;
    b = get(b);
    if (a == "+") {
      co[b]++;
    } else if (a == "-") {
      co[b]--;
    } else {
      cout << co[b] << endl;
    }
  }
}
