#include <bits/stdc++.h>
using namespace std;
int main() {
  map<long, int> mp;
  long long n, x, z = 0;
  char c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c >> x;
    z = 0;
    for (int j = 0; j < 18; j++) {
      z = (z * 2) + (x % 2);
      x /= 10;
    }
    if (c == '+') {
      mp[z]++;
    } else if (c == '-') {
      mp[z]--;
    } else {
      cout << mp[z] << endl;
    }
  }
  return 0;
}
