#include <bits/stdc++.h>
using namespace std;
unordered_map<long long int, int> cnt;
unordered_map<string, int> patt;
string str, s;
long long int a, t, i;
char c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> c;
    if (c == '+') {
      cin >> a;
      cnt[a]++;
      str = "";
      while (a > 0) {
        str += ((a % 10) % 2 == 0) ? "0" : "1";
        a /= 10;
      }
      if (str.length() != 19)
        for (i = str.length(); i <= 19; i++) str += "0";
      reverse(str.begin(), str.end());
      patt[str]++;
    } else if (c == '-') {
      cin >> a;
      cnt[a]--;
      str = "";
      while (a > 0) {
        str += ((a % 10) % 2 == 0) ? "0" : "1";
        a /= 10;
      }
      if (str.length() != 19)
        for (i = str.length(); i <= 19; i++) str += "0";
      reverse(str.begin(), str.end());
      patt[str]--;
    } else {
      cin >> s;
      if (s.length() != 19)
        for (i = s.length(); i <= 19; i++) s = "0" + s;
      cout << patt[s] << "\n";
    }
  }
  return 0;
}
