#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int arr[524288] = {};
  int q;
  cin >> q;
  while (q--) {
    char ch;
    string str;
    cin >> ch >> str;
    if (ch == '+') {
      int n = str.size();
      int val = 0;
      int x = 0;
      for (int i = n - 1; i >= 0; i--) {
        int pnt = 1;
        if ((str[i] - '0') % 2 == 0) pnt = 0;
        if (pnt) val += pow(2, x);
        x++;
      }
      arr[val]++;
    }
    if (ch == '-') {
      int n = str.size();
      int val = 0;
      int x = 0;
      for (int i = n - 1; i >= 0; i--) {
        int pnt = 1;
        if ((str[i] - '0') % 2 == 0) pnt = 0;
        if (pnt) val += pow(2, x);
        x++;
      }
      arr[val]--;
    }
    if (ch == '?') {
      int x = 0;
      int n = str.size();
      int val = 0;
      for (int i = n - 1; i >= 0; i--) {
        if ((str[i] - '0') == 1) val += pow(2, x);
        x++;
      }
      cout << arr[val] << endl;
    }
  }
  return 0;
}
