#include <bits/stdc++.h>
using namespace std;
int all[3000000] = {};
int convert(long long a) {
  int aux = 1, ans = 0, cur;
  while (a > 0) {
    cur = a % 10;
    if (cur % 2 == 1) ans += aux;
    aux *= 2;
    a /= 10;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    char a;
    int aux;
    long long n;
    cin >> a >> n;
    aux = convert(n);
    if (a == '+')
      all[aux]++;
    else if (a == '-')
      all[aux]--;
    else
      cout << all[aux] << '\n';
  }
  return 0;
}
