#include <bits/stdc++.h>
int main() {
  long long int occurance[530000] = {0}, t, i, j, symbolVal, len;
  char ch[30], numarr[30], symbol[30];
  scanf("%I64d", &t);
  for (i = 0; i < t; i++) {
    scanf("%s", ch);
    scanf("%s", numarr);
    len = strlen(numarr) - 1;
    symbolVal = 0;
    for (j = 0; numarr[j]; j++, len--)
      if (numarr[j] & 1) symbolVal += 1 << len;
    if (ch[0] == '+')
      occurance[symbolVal]++;
    else if (ch[0] == '-')
      occurance[symbolVal]--;
    else
      printf("%I64d\n", occurance[symbolVal]);
  }
  return 0;
}
