#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  string query;
  getline(cin, query);
  unordered_map<int, int> numbers;
  for (int i = 0; i < t; ++i) {
    getline(cin, query);
    uint64_t templ = 0;
    for (int j = 2; j < query.length(); ++j) {
      int num = query[j] - '0';
      if (num % 2 == 0) {
        templ = templ * 2;
      } else {
        templ = templ * 2 + 1;
      }
    }
    if (query[0] == '+') {
      auto result = numbers.find(templ);
      if (result == end(numbers))
        numbers.insert(make_pair(templ, 1));
      else
        ++result->second;
    } else if (query[0] == '-') {
      auto result = numbers.find(templ);
      if (result->second == 1)
        numbers.erase(result);
      else
        --result->second;
    } else {
      auto result = numbers.find(templ);
      if (result == end(numbers))
        cout << "0" << endl;
      else
        cout << result->second << endl;
    }
  }
  return 0;
}
