#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
string go(string x) {
  string temp = "";
  for (int i = x.size() - 1; i >= 0; i--) {
    if ((x[i] - '0') & 1) {
      temp = "1" + temp;
    } else {
      temp = "0" + temp;
    }
  }
  while (temp.size() < 18) {
    temp = "0" + temp;
  }
  return temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  while (n--) {
    char x;
    cin >> x;
    if (x == '+') {
      string s;
      cin >> s;
      m[go(s)] += 1;
    } else if (x == '-') {
      string s;
      cin >> s;
      m[go(s)] -= 1;
    } else {
      string s;
      cin >> s;
      while (s.size() < 18) {
        s = "0" + s;
      }
      cout << m[s] << '\n';
    }
  }
}
