#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
long long factorial(long long n) {
  return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res % mod;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
string convertt(long long n) {
  string s = to_string(n);
  for (long long i = 0; i < s.length(); i++)
    if ((s[i] - 48) & 1)
      s[i] = '1';
    else
      s[i] = '0';
  while (s.length() < 20) s = '0' + s;
  return s;
}
signed main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    map<string, long long> m;
    while (n--) {
      char ch;
      string s;
      cin >> ch >> s;
      if (ch == '-')
        m[convertt(stoll(s))]--;
      else if (ch == '+')
        m[convertt(stoll(s))]++;
      else
        cout << m[convertt(stoll(s))] << "\n";
    }
  }
  return 0;
}
