#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
string mask(long long x) {
  string s = "";
  while (x) {
    s = (char)((x & 1) + '0') + s;
    x /= 10;
  }
  while (s.size() <= 20) s = "0" + s;
  return s;
}
void get(long long x) { m[mask(x)]++; }
void er(long long x) { m[mask(x)]--; }
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    long long x;
    cin >> x;
    if (c == '+') get(x);
    if (c == '-') er(x);
    if (c == '?') {
      int ans = m[mask(x)];
      cout << ans << endl;
    }
  }
}
