#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int t;
  cin >> t;
  vector<long long int> v;
  map<string, long long int> ma;
  ma.clear();
  while (t--) {
    char c;
    string s;
    cin >> c >> s;
    if (c == '+') {
      string p = "";
      for (long long int i = 0; i < s.length(); i++) {
        if (p.length() == 0 && ((s[i] - '0') % 2 == 0)) continue;
        if ((s[i] - '0') % 2 == 0)
          p += '0';
        else
          p += '1';
      }
      if (p.length() == 0) p += '0';
      while (p.length() < 18) p = '0' + p;
      ma[p]++;
    } else if (c == '-') {
      string p = "";
      for (long long int i = 0; i < s.length(); i++) {
        if (p.length() == 0 && ((s[i] - '0') % 2 == 0)) continue;
        if ((s[i] - '0') % 2 == 0)
          p += '0';
        else
          p += '1';
      }
      if (p.length() == 0) p += '0';
      while (p.length() < 18) p = '0' + p;
      ma[p]--;
    } else if (c == '?') {
      long long int in = 0, flag = 0, cnt = 0;
      for (long long int i = 0; i < s.length(); i++) {
        if (s[i] == '1') {
          in = i;
          flag = 1;
          break;
        } else
          cnt++;
      }
      if (cnt == s.length()) {
        s = "";
        s += '0';
      }
      while (s.length() < 18) s = '0' + s;
      cout << ma[s] << endl;
    }
  }
}
