#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N = 1e6 + 6;
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b, b = t;
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long is_prime(long long n) {
  if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0)) return 0;
  for (long long i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
    if (n % i == 0) return 0;
  return 1;
}
long long modI(long long a, long long m) {
  long long m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m;
    a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long powbin(long long base, long long p) {
  long long mul;
  if (p == 1)
    mul = base;
  else {
    mul = (long long)powbin(base, p / 2);
    mul = (mul * mul) % MOD;
    if (p % 2) mul *= base;
  }
  return mul % MOD;
}
long long combination(long long n, long long r) {
  long long num = 1, den = 1;
  for (long long i = n; i >= n - r + 1; i--) {
    num = (num * i) % MOD;
  }
  for (long long i = r; i >= 1; i--) {
    den = (den * i) % MOD;
  }
  return (num * powbin(den, MOD - 2)) % MOD;
}
int main() {
  long long t;
  cin >> t;
  map<long long, long long> m;
  map<string, long long> m1;
  while (t--) {
    char c;
    cin >> c;
    long long d;
    cin >> d;
    if (c == '+') {
      m[d]++;
      string s = "";
      long long p = d;
      while (p > 0) {
        s += to_string((p % 10) % 2);
        p /= 10;
      }
      reverse((s).begin(), (s).end());
      m1[s]++;
    } else if (c == '-') {
      m[d]--;
      string s = "";
      long long p = d;
      while (p > 0) {
        s += to_string((p % 10) % 2);
        p /= 10;
      }
      reverse((s).begin(), (s).end());
      m1[s]--;
    } else {
      long long p = d;
      string test = "";
      while (p > 0) {
        test += to_string((p % 10) % 2);
        p /= 10;
      }
      reverse((test).begin(), (test).end());
      long long ans = 0;
      long long l = 0;
      long long len = test.length();
      while (len + l <= 18) {
        ans += m1[string(l, '0') + test];
        l++;
      }
      cout << ans << "\n";
    }
  }
  return 0;
}
