#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
long long n, m, x, y, k, ans, a[3 * N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  char c;
  while (t--) {
    cin >> c >> x;
    k = 0;
    m = 1;
    while (x > 0) {
      y = x % 10;
      if (y & 1) k += m;
      m *= 2;
      x /= 10;
    }
    if (c == '+')
      a[k]++;
    else if (c == '-')
      a[k]--;
    else
      cout << a[k] << endl;
  }
  return 0;
}
