#include <bits/stdc++.h>
using namespace std;
long long get(string a) {
  long long len = a.length();
  long long b = 0;
  long long cnt = 1;
  for (int i = len - 1; i >= 0; i--) {
    b += ((a[i] - '0') % 2) * cnt;
    cnt *= 2;
  }
  return b;
}
int p[262150];
int main() {
  int t;
  cin >> t;
  while (t--) {
    char c;
    cin >> c;
    string a;
    cin >> a;
    long long b = get(a);
    switch (c) {
      case '+': {
        p[b]++;
        break;
      }
      case '-': {
        p[b]--;
        break;
      }
      case '?': {
        cout << p[b] << endl;
        break;
      }
    }
  }
  return 0;
}
