#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int main(int argc, char *argv[]) {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    char ch;
    string str;
    cin >> ch >> str;
    string st;
    st = "aaaaaaaaaaaaaaaaaa";
    for (int j = 0; j < 18 - str.length(); ++j) {
      st[j] = '0';
    }
    for (int j = 18 - str.length(); j < 18; ++j) {
      if ((str[j - 18 + str.length()] - '0') % 2 == 0) {
        st[j] = '0';
      } else {
        st[j] = '1';
      }
    }
    if (ch == '+') {
      mp[st]++;
    }
    if (ch == '-') {
      mp[st]--;
    }
    if (ch == '?') {
      cout << mp[st] << endl;
    }
  }
  return 0;
}
