#include <bits/stdc++.h>
using namespace std;
long long a[300000] = {0};
int main() {
  string s;
  char c;
  long long p = 1, l, ind, i;
  long long t;
  cin >> t;
  while (t--) {
    cin >> c;
    cin >> s;
    if (c == '+') {
      p = 1;
      ind = 0;
      l = s.length();
      for (i = l - 1; i >= 0; i--) {
        if ((s[i] - '0') % 2 == 0) {
          p *= 2;
        } else {
          ind += p;
          p *= 2;
        }
      }
      a[ind]++;
    } else if (c == '-') {
      p = 1;
      ind = 0;
      l = s.length();
      for (i = l - 1; i >= 0; i--) {
        if ((s[i] - '0') % 2 == 0) {
          p *= 2;
        } else {
          ind += p;
          p *= 2;
        }
      }
      a[ind]--;
    } else {
      p = 1;
      ind = 0;
      l = s.length();
      for (i = l - 1; i >= 0; i--) {
        if ((s[i] - '0') % 2 == 0) {
          p *= 2;
        } else {
          ind += p;
          p *= 2;
        }
      }
      cout << a[ind] << endl;
    }
  }
  return 0;
}
