#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
long long int fast_exp(long long int base, long long int ex) {
  long long int res = 1;
  while (ex > 0) {
    if (ex % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    ex /= 2;
  }
  return res % mod;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  long long int re = gcd(b, a % b);
  return re;
}
map<long long, long long> ma;
map<long long, long long> mg;
long long conv(long long a) {
  long long f = 0;
  long long re = 0;
  long long b = 2;
  while (a) {
    long long j = a % 10;
    j = j % 2;
    if (j == 1) {
      long long v = fast_exp(b, f);
      re += v;
    }
    f++;
    a /= 10;
  }
  return re;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    char f;
    cin >> f;
    long long a;
    cin >> a;
    if (f == '+') {
      ma[a]++;
      long long k = conv(a);
      mg[k]++;
      continue;
    }
    if (f == '-') {
      ma[a]--;
      long long k = conv(a);
      mg[k]--;
      continue;
    }
    if (f == '?') {
      long long k = conv(a);
      cout << mg[k] << "\n";
    }
  }
  return 0;
}
