#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d\n", &t);
  map<string, int> cnt;
  while (t--) {
    char c;
    long long x;
    scanf("%c %lld\n", &c, &x);
    if (c == '+' || c == '-') {
      string s = "";
      while (x > 0) {
        s += '0' + x % 2;
        x /= 10;
      }
      while (s.size() && s[(int)s.size() - 1] == '0')
        s.erase((int)s.size() - 1);
      cnt[s] += c == '+' ? 1 : -1;
    } else {
      string s = "";
      while (x > 0) {
        s += '0' + x % 2;
        x /= 10;
      }
      while (s.size() && s[(int)s.size() - 1] == '0')
        s.erase((int)s.size() - 1);
      printf("%d\n", cnt[s]);
    }
  }
}
