#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  map<string, int> a;
  for (int i = 0; i < n; i++) {
    char t;
    string x;
    cin >> t >> x;
    while (x.size() < 18) {
      x = "0" + x;
    }
    for (auto&& j : x) {
      j = j % 2;
    }
    if (t == '+') {
      a[x]++;
    } else if (t == '-')
      a[x]--;
    else {
      cout << a[x] << "\n";
    }
  }
}
