#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
const unsigned int MOD = 1000000007;
long long int inf = 1000000000000000000;
template <class T>
T power(T a, long long int n) {
  T res = 1;
  while (n > 0) {
    if (n % 2) res = (res * a);
    a = (a * a), n = n / 2;
  }
  return res;
}
unsigned int factorial(unsigned int n) {
  if (n == 0) return 1;
  return n * factorial(n - 1);
}
bool isprime(int n) {
  if (n == 0) return false;
  if (n <= 1) return true;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
inline long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
inline long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
int getsum(long long int n) {
  int sum;
  for (sum = 0; n > 0; sum += n % 10, n /= 10)
    ;
  return sum;
}
void tobin(int n) {
  int binaryNum[32];
  int i = 0;
  while (n > 0) {
    binaryNum[i] = n % 2;
    n = n / 2;
    i++;
  }
  for (int j = i - 1; j >= 0; j--) cout << binaryNum[j];
}
long long int nCr(long long int n, long long int k) {
  if (k > n) return 0;
  long long int res = 1;
  if (k > n - k) k = n - k;
  for (int i = 0; i < k; i++) res *= (n - i), res /= (i + 1);
  return res;
}
bool cosmo(string s) {
  bool flag = 0;
  for (auto x : s)
    if (x != '0') flag = 1;
  return flag;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int q;
  cin >> q;
  string temp = "00000000000000000000";
  map<string, long long int> maps;
  while (q--) {
    char c;
    string a;
    cin >> c >> a;
    string val = temp;
    long long int p = val.length() - 1;
    reverse(a.begin(), a.end());
    ;
    for (auto x : a) {
      long long int z = x - '0';
      if (z % 2) val[p] = '1';
      p--;
    }
    if (c == '+')
      maps[val]++;
    else if (c == '-')
      maps[val]--;
    else {
      cout << maps[val] << endl;
    }
  }
}
