#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const long long K = 1;
map<long long, long long> M;
long long f(long long x) {
  int i;
  long long preans = 0, ans = 0;
  for (i = 0; i < 18; i++) {
    preans = preans * 10 + x % 2;
    x /= 10;
  }
  for (i = 0; i < 18; i++) {
    ans = ans * 10 + preans % 10;
    preans /= 10;
  }
  return ans;
}
int main() {
  char c;
  int i, t;
  long long a;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> c >> a;
    if (c == '+') M[f(a)]++;
    if (c == '-') M[f(a)]--;
    if (c == '?') cout << M[f(a)] << endl;
  }
  return 0;
}
