#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int alphabet = 26;
const int MAXINT = 1e6;
int n, c = 0, cont[MAXINT] = {};
char sim;
long long num;
map<long long, int> freq;
long long POW(int p, int q) {
  long long r = 1;
  for (int i = 0; i < q; i++) r *= p;
  return r;
}
long long to_binary(long long x) {
  long long r = 0;
  int i = 0;
  while (x != 0) {
    int resto = x % 10;
    if (resto % 2 == 1) r += POW(2, i);
    i++;
    x = x / 10;
  }
  return r;
}
int main() {
  cin >> n;
  while (n--) {
    cin >> sim >> num;
    if (sim == '+')
      cont[to_binary(num)]++;
    else if (sim == '-')
      cont[to_binary(num)]--;
    else
      cout << cont[to_binary(num)] << endl;
  }
  return 0;
}
