#include <bits/stdc++.h>
using namespace std;
using namespace std;
string func(long long int n) {
  string s = "";
  while (n) {
    if ((n % 10) % 2)
      s = "1" + s;
    else
      s = "0" + s;
    n /= 10;
  }
  while (s.length() < 18) s = "0" + s;
  return s;
}
signed main() {
  long long int t;
  cin >> t;
  map<string, long long int> ma;
  while (t--) {
    long long int n;
    char ch;
    cin >> ch;
    if (ch == '+') {
      cin >> n;
      string s = func(n);
      ma[s]++;
    } else if (ch == '-') {
      cin >> n;
      string s = func(n);
      ma[s]--;
    } else {
      string s;
      cin >> s;
      while (s.length() < 18) s = "0" + s;
      cout << ma[s] << endl;
    }
  }
  return 0;
}
