#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  multiset<long long int> s;
  map<string, int> mp;
  while (t--) {
    char ch;
    long long int x;
    cin >> ch >> x;
    string str(18, '0');
    string temp = to_string(x);
    int j = 17;
    for (int i = ((int)(temp).size()) - 1; i >= 0; i--) {
      if ((temp[i] - '0') % 2 != 0) {
        str[j] = '1';
      }
      j--;
    }
    if (ch == '+') {
      mp[str]++;
    } else if (ch == '-') {
      mp[str]--;
    } else {
      cout << mp[str] << "\n";
    }
  }
}
