#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  char ch;
  long long num;
  vector<int> v;
  map<long long, int> cnt;
  cin >> t;
  while (t--) {
    cin >> ch >> num;
    if (ch == '+') {
      v.clear();
      while (num) {
        int module_n = num % 10;
        int bin_n = module_n % 2;
        num /= 10;
        v.push_back(bin_n);
      }
      long long conv_n = 0;
      for (int i = v.size() - 1; i >= 0; i--) {
        conv_n *= 10;
        conv_n += v[i];
      }
      cnt[conv_n]++;
    } else if (ch == '-') {
      v.clear();
      while (num) {
        int module_n = num % 10;
        int bin_n = module_n % 2;
        num /= 10;
        v.push_back(bin_n);
      }
      long long conv_n = 0;
      for (int i = v.size() - 1; i >= 0; i--) {
        conv_n *= 10;
        conv_n += v[i];
      }
      cnt[conv_n]--;
    } else {
      if (cnt.find(num) == cnt.end()) {
        cout << "0\n";
      } else {
        cout << cnt[num] << endl;
      }
    }
  }
  return 0;
}
