#include <bits/stdc++.h>
inline int Rand() { return (rand() << 16) | rand(); }
using namespace std;
const int N = 200005;
const double eps = 1e-9;
map<string, int> m;
int main() {
  int n;
  cin >> n;
  char ch;
  string s;
  for (int i = 1; i <= n; ++i) {
    cin >> ch >> s;
    for (int i = 0; i < s.size(); ++i) s[i] = char((s[i] % 2) + '0');
    int j = s.size();
    for (int i = 1; i <= 18 - j; ++i) s = '0' + s;
    if (ch == '+') m[s]++;
    if (ch == '-') m[s]--;
    if (ch == '?') cout << m[s] << endl;
  }
  return 0;
}
