#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  map<long long, string> a;
  map<string, long long> b;
  for (int i = 0; i < q; i++) {
    char c;
    cin >> c;
    if (c == '+') {
      long long ch;
      cin >> ch;
      if (a[ch] == "") {
        string s = "";
        long long kop = ch;
        while (ch > 0) {
          int x = ch % 10;
          ch /= 10;
          if (x % 2 == 0)
            s = '0' + s;
          else
            s = '1' + s;
        }
        a[kop] = s;
        ch = kop;
      }
      string s = a[ch];
      while (s.size() < 18) {
        s = '0' + s;
      }
      b[s]++;
    } else if (c == '-') {
      long long ch;
      cin >> ch;
      string s = a[ch];
      while (s.size() < 18) {
        s = '0' + s;
      }
      b[s]--;
    } else {
      string s;
      cin >> s;
      while (s.size() < 18) {
        s = '0' + s;
      }
      cout << b[s] << endl;
    }
  }
}
