#include <bits/stdc++.h>
using namespace std;
map<long long, int> mpp, mp2;
int main() {
  long long q, x, y;
  scanf("%I64d", &q);
  char s[10], ss[30], st[30];
  while (q--) {
    scanf("%s%I64d", s, &x);
    if (strcmp(s, "+") == 0) {
      mpp[x]++;
      sprintf(ss, "%I64d", x);
      int ln = strlen(ss), flag = 0, j = 0;
      for (int i = 0; i < ln; i++) {
        if (flag == 0) {
          if (ss[i] % 2 == 1) {
            flag = 1;
            st[j++] = '1';
          }
        } else {
          if (ss[i] % 2 == 1)
            st[j++] = '1';
          else
            st[j++] = '0';
        }
      }
      if (j == 0) st[j++] = '0';
      st[j] = '\0';
      y = atoll(st);
      mp2[y]++;
    } else if (strcmp(s, "-") == 0) {
      mpp[x]--;
      sprintf(ss, "%I64d", x);
      int ln = strlen(ss), flag = 0, j = 0;
      for (int i = 0; i < ln; i++) {
        if (flag == 0) {
          if (ss[i] % 2 == 1) {
            flag = 1;
            st[j++] = '1';
          }
        } else {
          if (ss[i] % 2 == 1)
            st[j++] = '1';
          else
            st[j++] = '0';
        }
      }
      if (j == 0) st[j++] = '0';
      st[j] = '\0';
      y = atoll(st);
      mp2[y]--;
    } else {
      printf("%d\n", mp2[x]);
    }
  }
}
