#include <bits/stdc++.h>
using namespace std;
map<long long, long long> h;
long long solve(long long a) {
  long long b = 0;
  long long p = 1;
  while (a) {
    if (a % 2) b += p;
    a /= 10;
    p *= 2;
  }
  return b;
}
void init(long long a, char &c) {
  long long b = 0;
  b = solve(a);
  if (c == '+') {
    if (h.count(b) == 0)
      h[b] = 1;
    else
      h[b]++;
  } else
    h[b]--;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    char c;
    long long a, s;
    cin >> c;
    if (c != '?') {
      cin >> a;
      init(a, c);
    } else {
      cin >> s;
      long long b = solve(s);
      cout << h[b] << endl;
    }
  }
}
