#include <bits/stdc++.h>
using namespace std;
struct Node {
  Node* next[2];
  int v;
  Node() {
    next[0] = next[1] = nullptr;
    v = 0;
  }
};
Node* root;
void f(string s, int a) {
  Node* n = root;
  for (int i = 0; i < s.size(); i++) {
    int c = (s[s.size() - 1 - i] - '0') % 2;
    if (n->next[c] == nullptr) {
      n->next[c] = new Node();
    }
    n = n->next[c];
    n->v += a;
  }
}
int g(string s) {
  Node* n = root;
  for (int i = 0; i < s.size(); i++) {
    int c = (s[s.size() - 1 - i] - '0') % 2;
    if (n->next[c] == nullptr) return 0;
    n = n->next[c];
  }
  return n->v;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  root = new Node();
  map<long long, int> m;
  while (t--) {
    char c;
    long long n;
    string s;
    cin >> c >> n;
    s = to_string(n);
    while (s.size() != 18) s = '0' + s;
    if (c == '+') {
      m[n]++;
      f(s, 1);
    } else if (c == '-') {
      m[n]--;
      f(s, -1);
    } else {
      cout << g(s) << endl;
    }
  }
}
