#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> l;
int main() {
  long long int t;
  cin >> t;
  long long int a[18][2] = {0};
  while (t--) {
    char p;
    cin >> p;
    if (p == '+') {
      long long int k;
      cin >> k;
      string s;
      int h = 0;
      while (k != 0) {
        int y = k % 10;
        y = y % 2;
        string f = to_string(y);
        s = f + s;
        l[s]++;
        k = k / 10;
        h++;
      }
      for (int i = h; i < 18; i++) {
        s = '0' + s;
        l[s]++;
      }
    }
    if (p == '-') {
      long long int k;
      cin >> k;
      string s;
      int h = 0;
      while (k != 0) {
        int y = k % 10;
        y = y % 2;
        string f = to_string(y);
        s = f + s;
        l[s]--;
        k = k / 10;
        h++;
      }
      for (int i = h; i < 18; i++) {
        s = '0' + s;
        l[s]--;
      }
    }
    if (p == '?') {
      string s;
      cin >> s;
      int h = s.length();
      for (int i = h; i < 18; i++) {
        s = '0' + s;
      }
      cout << l[s] << endl;
    }
  }
  return 0;
}
