#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<long long, int> umap;
  while (n--) {
    char x;
    cin >> x;
    long long a, pat = 0, mask = 1;
    cin >> a;
    if (x == '+') {
      while (a) {
        int temp = a % 10;
        if (temp % 2 != 0) {
          pat += mask;
        }
        mask <<= 1;
        a /= 10;
      }
      umap[pat]++;
    } else if (x == '-') {
      while (a) {
        int temp = a % 10;
        if (temp % 2 != 0) {
          pat += mask;
        }
        mask <<= 1;
        a /= 10;
      }
      umap[pat]--;
    } else {
      while (a) {
        int temp = a % 10;
        if (temp % 2 != 0) {
          pat += mask;
        }
        mask <<= 1;
        a /= 10;
      }
      cout << umap[pat] << endl;
    }
  }
}
