#include <bits/stdc++.h>
using namespace std;
map<string, int> Q;
int n;
int main() {
  scanf("%d", &n);
  getchar();
  while (n--) {
    char c;
    string a;
    cin >> c;
    cin >> a;
    string numa;
    int k = 0;
    for (int i = 0; i < 18; i++) {
      if (i < 18 - a.size())
        numa += '0';
      else {
        int x = a[k++] - '0';
        char y = x % 2 == 0 ? '0' : '1';
        numa += y;
      }
    }
    if (c == '+')
      Q[numa]++;
    else if (c == '-')
      Q[numa]--;
    else
      printf("%d\n", Q[numa]);
  }
  return 0;
}
