#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
map<string, int> mp;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    char op[2], num[20];
    scanf("%s%s", op, num);
    int len = strlen(num);
    string temp = "";
    for (int i = 0; i < 18 - len; ++i) temp += '0';
    for (int i = 0; i < len; ++i) temp += num[i] & 1 ? '1' : '0';
    if (op[0] == '+') ++mp[temp];
    if (op[0] == '-') --mp[temp];
    if (op[0] == '?') printf("%d\n", mp[temp]);
  }
  return 0;
}
