#include <bits/stdc++.h>
using namespace std;
string convert(long long x) {
  string s;
  while (x > 0) {
    int d = x % 10;
    if (d % 2 == 0)
      s = '0' + s;
    else
      s = '1' + s;
    x /= 10;
  }
  while (s.length() < 19) {
    s = "0" + s;
  }
  return s;
}
int main() {
  int t;
  cin >> t;
  map<string, int> ms;
  while (t--) {
    char c;
    cin >> c;
    if (c == '+') {
      long long x;
      cin >> x;
      string s = convert(x);
      ms[s]++;
    } else if (c == '-') {
      long long x;
      cin >> x;
      string s = convert(x);
      ms[s]--;
    } else {
      string s;
      cin >> s;
      while (s.length() < 19) s = "0" + s;
      cout << ms[s] << endl;
    }
  }
  return 0;
}
