#include <bits/stdc++.h>
using namespace std;
long long i, n, j, k;
char c;
string s;
map<string, int> m;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> c >> k;
    j = 0;
    s = "000000000000000000";
    while (k > 0) {
      j++;
      if ((k % 10) % 2 != 0) s[18 - j] = '1';
      k = k / 10;
    }
    if (c == '+') m[s]++;
    if (c == '-') m[s]--;
    if (c == '?') cout << m[s] << endl;
  }
}
