#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
string fun(long long n) {
  string ret = "";
  while (n) {
    long long z = n % 10;
    if (z % 2 == 0)
      ret += '0';
    else
      ret += '1';
    n /= 10;
  }
  int c = 18 - ret.length();
  for (int i = 0; i < c; i++) ret += '0';
  reverse(ret.begin(), ret.end());
  return ret;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    char s[3];
    scanf("%s", s);
    if (s[0] == '+') {
      long long n;
      scanf("%lld", &n);
      string s1 = fun(n);
      mp[s1]++;
    } else if (s[0] == '-') {
      long long n;
      scanf("%lld", &n);
      string s1 = fun(n);
      mp[s1]--;
    } else {
      string s1;
      cin >> s1;
      reverse(s1.begin(), s1.end());
      int c = 18 - s1.length();
      for (int i = 0; i < c; i++) s1 += '0';
      reverse(s1.begin(), s1.end());
      printf("%d\n", mp[s1]);
    }
  }
  return 0;
}
