#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<string, int> memo;
  int t;
  cin >> t;
  string s;
  s.reserve(30);
  for (int i = 0; i < t; i++) {
    char q;
    cin >> q;
    if (q == '+') {
      cin >> s;
      while (s.size() != 18) s = "0" + s;
      for (char &c : s) {
        if ((c - '0') % 2)
          c = '1';
        else
          c = '0';
      }
      if (!memo.count(s)) {
        memo[s] = 1;
      } else {
        memo[s]++;
      }
    } else if (q == '-') {
      cin >> s;
      while (s.size() != 18) s = "0" + s;
      for (char &c : s) {
        if ((c - '0') % 2)
          c = '1';
        else
          c = '0';
      }
      memo[s]--;
    } else {
      cin >> s;
      while (s.size() != 18) s = "0" + s;
      cout << memo[s] << endl;
    }
  }
  return 0;
}
