#include <bits/stdc++.h>
using namespace std;
long long Q(long long n) {
  long long num = 0;
  string s = "";
  while (n > 0) {
    if ((n % 10) % 2 == 0)
      s += '0';
    else
      s += '1';
    n /= 10;
  }
  stringstream ss;
  reverse(s.begin(), s.end());
  ss << s;
  ss >> num;
  return num;
}
int main() {
  long long t, n;
  map<long long, long long> v;
  map<long long, long long> p;
  cin >> t;
  char c;
  while (t--) {
    cin >> c >> n;
    if (c == '+') {
      v[n]++;
      p[Q(n)]++;
    } else if (c == '-') {
      v[n]--;
      p[Q(n)]--;
    } else {
      cout << p[Q(n)] << endl;
    }
  }
  return 0;
}
