#include <bits/stdc++.h>
using namespace std;
map<string, long long> mp;
int main() {
  long long n, ans, r;
  cin >> n;
  char ch;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> ch >> a;
    string s = "";
    if (ch == '+') {
      for (int j = 0; j < 20; j++) {
        if (a % 2 == 1)
          s += '1';
        else
          s += '0';
        a /= 10;
      }
      reverse(s.begin(), s.end());
      mp[s]++;
    } else if (ch == '-') {
      s = "";
      for (int j = 0; j < 20; j++) {
        if (a % 2 == 1)
          s += '1';
        else
          s += '0';
        a /= 10;
      }
      reverse(s.begin(), s.end());
      mp[s]--;
    } else if (ch == '?') {
      for (int j = 0; j < 20; j++) {
        if (a % 2 == 1)
          s += '1';
        else
          s += '0';
        a /= 10;
      }
      reverse(s.begin(), s.end());
      cout << mp[s] << endl;
    }
  }
  return 0;
}
