#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, in;
  cin >> n;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    char ope;
    cin >> ope >> in;
    long long bi = 0, tmp = in, p = 1;
    while (tmp > 0) {
      if ((tmp % 10) % 2 == 1) bi += p;
      tmp /= 10;
      p *= 10;
    }
    if (ope == '+')
      m[bi]++;
    else if (ope == '-')
      m[bi]--;
    else
      cout << m[bi] << endl;
  }
  return 0;
}
