#include <bits/stdc++.h>
using namespace std;
long long int Encrypt(long long int a) {
  vector<long long int> vv;
  for (long long int n = a; n > 0; n /= 10) {
    vv.push_back((n % 10) % 2);
  }
  long long int ans = 0;
  for (long long int i = vv.size() - 1; i >= 0; --i) {
    ans = ans * 10 + vv[i];
  }
  return ans;
}
int main() {
  long long int t;
  cin >> t;
  map<long long int, long long int> mm;
  for (long long int i = 0; i < t; i++) {
    char c;
    cin >> c;
    if (c == '+') {
      long long int temp;
      cin >> temp;
      mm[Encrypt(temp)]++;
    } else if (c == '-') {
      long long int temp;
      cin >> temp;
      mm[Encrypt(temp)]--;
    } else {
      long long int temp;
      cin >> temp;
      cout << mm[temp] << endl;
    }
  }
  return 0;
}
