#include <bits/stdc++.h>
using namespace std;
long long i, j;
long long calc(long long num) {
  long long ans = 0;
  j = 0;
  while (num > 0) {
    long long temp = num % 10;
    num /= 10;
    long long val = temp % 2;
    ans += (1 << j) * val;
    j++;
  }
  return ans;
}
int main() {
  map<long long, long long> arr;
  long long T;
  cin >> T;
  while (T--) {
    char ch;
    cin >> ch;
    if (ch == '+') {
      long long N;
      cin >> N;
      long long foo = calc(N);
      arr[foo]++;
    } else if (ch == '-') {
      long long N;
      cin >> N;
      long long foo = calc(N);
      arr[foo]--;
    } else {
      long long N;
      cin >> N;
      long long foo = calc(N);
      cout << arr[foo] << endl;
    }
  }
  return 0;
}
