#include <bits/stdc++.h>
using namespace std;
const long long N = 500;
struct b {
  string s1;
  string s2;
  bool operator<(const b& other) const {
    if (this->s1 < other.s1) return true;
    return false;
  }
};
map<b, int> mp;
int main() {
  int n, i;
  cin >> n;
  while (n--) {
    getchar();
    string tmp;
    char c;
    cin >> c >> tmp;
    int len = tmp.length(), j = 0;
    b t;
    for (i = len - 1; j <= 18; j++) {
      if (i >= 0) {
        t.s2 += tmp[i];
        t.s1 += (tmp[i] - '0') % 2 + '0';
        i--;
      } else {
        t.s2 += '0';
        t.s1 += '0';
      }
    }
    if (c == '+') {
      mp[t]++;
    } else if (c == '-') {
      map<b, int>::iterator it;
      it = mp.find(t);
      if (it->second == 1)
        mp.erase(t);
      else
        mp[t]--;
    } else if (c == '?') {
      int ans = 0;
      ans += mp[t];
      cout << ans << endl;
    }
  }
  return 0;
}
