#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> MP;
inline int tob(long long a) {
  long long temp = a, res = 1, ans = 0;
  while (temp > 0) {
    if (temp & 1) ans += res;
    temp = temp / 10;
    res = res << 1;
  }
  return ans;
}
int main() {
  int t;
  char c;
  long long a;
  cin >> t;
  while (t--) {
    scanf(" %c%I64d", &c, &a);
    if (c == '+') {
      MP[tob(a)]++;
    } else if (c == '-') {
      MP[tob(a)]--;
    } else if (c == '?') {
      printf("%d\n", MP[tob(a)]);
    }
  }
  return 0;
}
