#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 3e5;
map<string, int> f;
string convert(string t) {
  while (t.size() != 18) {
    t = '0' + t;
  }
  for (int i = 0; i < t.size(); ++i) {
    int d = t[i] - '0';
    t[i] = d % 2 + '0';
  }
  return t;
}
int main() {
  ios ::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    string t;
    char c;
    cin >> c >> t;
    t = convert(t);
    if (c == '+') {
      f[t]++;
    } else if (c == '-') {
      f[t]--;
    } else {
      cout << f[t] << endl;
    }
  }
  return 0;
}
