#include <bits/stdc++.h>
inline constexpr int ctoi(const char c) { return c - '0'; }
inline constexpr char itoc(const int n) { return n + '0'; }
template <typename T>
inline T clamp(const T& n, const T& lo, const T& hi) {
  return std::max(lo, std::min(n, hi));
}
template <class T>
inline void sort(T& a) {
  std::sort(a.begin(), a.end());
}
template <class T1, class T2>
inline void sort(T1& a, T2 comp) {
  sort(a.begin(), a.end(), comp);
}
template <class T>
inline int read(T& n) {
  return std::cin >> n ? 1 : -1;
}
template <typename T, typename... types>
inline int read(T& n, types&... args) {
  return read(n) == -1 ? -1 : read(args...) + 1;
}
template <class T>
inline void write(const T& n) {
  std::cout << n;
}
template <typename T, typename... types>
inline void write(const char sep, T& n, types&... args) {
  write(n);
  write(sep);
  write(sep, args...);
}
template <typename T>
inline constexpr bool odd(const T a) {
  return bool(a & 1);
}
template <typename T>
inline constexpr bool even(const T a) {
  return !odd(a);
}
template <class T>
inline unsigned int mod(const T m, const T n) {
  return m >= 0 ? m % n : (n - abs(m % n)) % n;
}
template <class T>
class reader {
 public:
  void operator()(T& t) const { std::cin >> t; }
};
template <class CONTAINER, class READ_Fn>
void read(CONTAINER& v, const unsigned int size,
          const READ_Fn& rfn = reader<typename CONTAINER::value_type>()) {
  for (int i = 0; i < size; ++i) {
    rfn(v[i]);
  }
}
auto pair_cmp = [](const std::pair<signed long, signed long>& p1,
                   const std::pair<signed long, signed long>& p2) {
  return (p1.first < p2.first) ||
         (p1.first == p2.first && p1.second < p2.second);
};
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int s = 300000;
  vector<int> P(s, 0);
  int n;
  read(n);
  while (n--) {
    char c;
    signed long long x;
    read(c, x);
    int N = 0;
    int p = 1;
    while (x > 0) {
      N += p * ((x % 10) % 2 == 1);
      p *= 2;
      x /= 10;
    }
    if (c != '?') {
      int inc = (c == '+') ? 1 : -1;
      P[N] += inc;
    } else {
      write(P[N]);
      write('\n');
    }
  }
  return 0;
}
