#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  while (a > 0 && b > 0) {
    if (a > b)
      a %= b;
    else
      b %= a;
  }
  return (a + b);
}
map<string, int> pool;
string normalize(string s) {
  for (int i = 0; i < s.size(); ++i) {
    if ((s[i] - '0') % 2 == 0) {
      s[i] = '0';
    } else {
      s[i] = '1';
    }
  }
  while (s.size() != 19) s = '0' + s;
  return s;
}
void deleteNumber(string s) {
  s = normalize(s);
  pool[s] -= 1;
}
void addNumber(string s) {
  s = normalize(s);
  pool[s] += 1;
}
void solveTask() {
  int t;
  cin >> t;
  while (t) {
    char typeOperation;
    cin >> typeOperation;
    if (typeOperation == '+') {
      string s;
      cin >> s;
      addNumber(s);
    } else if (typeOperation == '-') {
      string s;
      cin >> s;
      deleteNumber(s);
    } else {
      string s;
      cin >> s;
      s = normalize(s);
      cout << pool[s] << endl;
    }
    --t;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  solveTask();
  return 0;
}
