#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    T t = bigmod(p, e / 2, M);
    return (t * t) % M;
  }
  return (bigmod(p, e - 1, M) * p) % M;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T multimod(T a, T b, T m) {
  T ans = 0ll;
  a %= m, b %= m;
  while (b) {
    if (b & 1ll) ans = m - ans > a ? (ans + a) : (ans + a - m);
    b >>= 1ll;
    a = (m - a) > a ? a + a : a + a - m;
  }
  return (T)ans;
}
int main() {
  int i, t, j, k, u, v, w;
  scanf("%d", &t);
  char num[20];
  char op;
  map<string, int> M;
  M.clear();
  while (t--) {
    scanf(" %c", &op);
    scanf(" %s", num);
    string str = "";
    int l = 18 - strlen(num);
    for (i = 0; i < l; i++) str += '0';
    for (i = 0; i < strlen(num); i++) str += (num[i] % 2 ? '1' : '0');
    if (op == '+')
      M[str]++;
    else if (op == '-')
      M[str]--;
    else
      printf("%d\n", M[str]);
  }
  return 0;
}
