#include <bits/stdc++.h>
using namespace std;
long long t = 1;
string conv1(string s) {
  string ans = s;
  long long len = int(ans.size());
  for (long long i = 0; i < 20 - len; i += 1) ans = "0" + ans;
  return ans;
}
string conv(long long x) {
  string ans = "";
  while (x > 0) {
    if ((x % 10) % 2 == 1)
      ans += "1";
    else
      ans += "0";
    x /= 10;
  }
  reverse((ans).begin(), (ans).end());
  long long len = int(ans.size());
  for (long long i = 0; i < 20 - len; i += 1) {
    ans = "0" + ans;
  }
  return ans;
}
void solve() {
  long long n;
  cin >> n;
  map<string, long long> mapa;
  while (n--) {
    char c;
    long long x;
    string s;
    cin >> c;
    if (c == '+') {
      cin >> x;
      mapa[conv(x)]++;
    } else if (c == '-') {
      cin >> x;
      mapa[conv(x)]--;
    } else {
      cin >> s;
      cout << mapa[conv1(s)] << "\n";
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (t--) solve();
  return 0;
}
