#include <bits/stdc++.h>
unsigned long long f(unsigned long long n) {
  unsigned long long bits = 1;
  for (; n; n /= 10) {
    unsigned digit = n % 10;
    bits *= 2;
    bits += digit % 2;
  }
  for (; bits && bits % 2 == 0; bits /= 2)
    ;
  return bits;
}
int main() {
  unsigned long long n;
  std::cin >> n;
  std::unordered_map<unsigned long long, unsigned long long> M;
  for (char c; std::cin >> c >> n;) {
    if (c == '+')
      ++M[f(n)];
    else if (c == '-')
      --M[f(n)];
    else
      std::cout << M[f(n)] << '\n';
  }
}
