#include <bits/stdc++.h>
using namespace std;
long long int rand(long long int a, long long int b) {
  return (a + (rand() % (b - a + 1)));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long int a, t, b, i, j, k, x, y, l, m, n;
  char c;
  cin >> t;
  map<long long int, long long int> ma;
  while (t--) {
    cin >> c >> b;
    long long int tmp = 0;
    if (c == '+') {
      k = 1;
      a = 0;
      while (b) {
        m = b % 10;
        m = m % 2;
        a = a + (k * m);
        k = k * 10;
        b = b / 10;
      }
      ma[a]++;
    } else if (c == '-') {
      k = 1;
      a = 0;
      while (b) {
        m = b % 10;
        m = m % 2;
        a = a + (k * m);
        k = k * 10;
        b = b / 10;
      }
      ma[a]--;
    } else {
      k = 1;
      a = 0;
      while (b) {
        m = b % 10;
        m = m % 2;
        a = a + (k * m);
        k = k * 10;
        b = b / 10;
      }
      cout << ma[a] << '\n';
    }
  }
  return 0;
}
