#include <bits/stdc++.h>
using namespace std;
long long get_pattern(long long x) {
  long long ans = 0;
  int pos = 0;
  while (x > 0) {
    ans += (((x % 10) % 2) * pow(10LL, pos));
    x /= 10;
    pos++;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  map<long long, int> a;
  long long t, x;
  char q;
  cin >> t;
  while (t--) {
    cin >> q >> x;
    if (q == '+')
      a[get_pattern(x)]++;
    else if (q == '-')
      a[get_pattern(x)]--;
    else {
      cout << a[x] << endl;
    }
  }
}
