#include <bits/stdc++.h>
using namespace std;
struct comparator {
  bool operator()(int i, int j) { return i > j; }
};
priority_queue<int, std::vector<int>, comparator> minHeap;
unordered_map<long long, long long> binary_numbers;
long long convert(long long a) {
  long long r, m = 1, ans = 0;
  while (a > 0) {
    r = a % 10;
    a /= 10;
    ans += m * (r % 2);
    m *= 10;
  }
  return ans;
}
int main() {
  long long num;
  int n;
  cin >> n;
  char op;
  for (int i = int(0); i <= int(n - 1); ++i) {
    cin >> op;
    cin >> num;
    long long number = convert(num);
    if (op == '+') {
      binary_numbers[number]++;
    } else if (op == '-') {
      binary_numbers[number]--;
      if (binary_numbers[number] == 0) binary_numbers.erase(number);
    } else {
      cout << binary_numbers[number] << endl;
    }
  }
  return 0;
}
