#include <bits/stdc++.h>
using namespace std;
int dat[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2];
int main() {
  int t, i;
  scanf("%d", &t);
  long long var;
  char str[20];
  char ch = '+';
  int arr[18];
  while (t--) {
    cin >> ch;
    for (i = 0; i <= 17; i++) {
      arr[i] = 0;
    }
    if (ch == '+') {
      scanf("%I64d", &var);
      i = 0;
      while (var != 0) {
        arr[i] = (var % 10) % 2;
        var /= 10;
        i++;
      }
      dat[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]]
         [arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]]
         [arr[16]][arr[17]]++;
    } else if (ch == '-') {
      scanf("%I64d", &var);
      i = 0;
      while (var != 0) {
        arr[i] = (var % 10) % 2;
        var /= 10;
        i++;
      }
      dat[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]][arr[7]]
         [arr[8]][arr[9]][arr[10]][arr[11]][arr[12]][arr[13]][arr[14]][arr[15]]
         [arr[16]][arr[17]]--;
    } else {
      scanf("%s", &str);
      i = 0;
      while (str[i] != '\0') {
        i++;
      }
      int j = 0;
      while (j < i) {
        arr[j] = str[i - j - 1] - '0';
        j++;
      }
      printf("%d ", dat[arr[0]][arr[1]][arr[2]][arr[3]][arr[4]][arr[5]][arr[6]]
                       [arr[7]][arr[8]][arr[9]][arr[10]][arr[11]][arr[12]]
                       [arr[13]][arr[14]][arr[15]][arr[16]][arr[17]]);
      printf("\n");
    }
  }
}
