#include <bits/stdc++.h>
using namespace std;
map<string, multiset<string> > ma;
string get_pat(string &s) {
  string res = "";
  int first_odd = -1;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] - '0') & 1) {
      first_odd = i;
      break;
    }
  }
  if (first_odd == -1) {
    return "0";
  }
  for (int i = first_odd; i < s.size(); i++) {
    if ((s[i] - '0') & 1) {
      res += "1";
    } else {
      res += "0";
    }
  }
  return res;
}
int main() {
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int query = 0; query < t; query++) {
    string op, num;
    cin >> op >> num;
    if (op == "+") {
      string s = get_pat(num);
      ma[s].insert(num);
    } else if (op == "-") {
      string s = get_pat(num);
      ma[s].erase(ma[s].find(num));
    } else {
      string s = get_pat(num);
      printf("%d\n", ma[s].size());
    }
  }
  return 0;
}
