#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> m;
  int T;
  cin >> T;
  getchar();
  string tmp;
  for (int i = 0; i < T; i++) {
    getline(cin, tmp);
    string a = "000000000000000000";
    int j = 17;
    for (int i = tmp.length() - 1; tmp[i] != ' '; i--) {
      a[j--] = ((tmp[i] - '0') % 2) + '0';
    }
    if (tmp[0] == '+') {
      m[a]++;
    } else if (tmp[0] == '-') {
      m[a]--;
    } else {
      cout << m[a] << endl;
    }
  }
}
