#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 18;
int b[maxn];
string str;
int main() {
  char a;
  int n;
  scanf("%d", &n);
  while (n--) {
    scanf(" %c", &a);
    cin >> str;
    int x = 0, len = str.length();
    for (int i = len - 1; i >= 0; i--)
      if (str[i])
        if ((str[i] - '0') % 2) x = x + pow(2, len - i - 1);
    if (a == '+')
      b[x]++;
    else if (a == '-')
      b[x]--;
    else
      cout << b[x] << endl;
  }
}
