#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 200031;
int cnt[1 << 21];
int tests;
string st;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> tests;
  for (; tests; --tests) {
    cin >> st;
    if (st == "+" || st == "-") {
      string temp;
      cin >> temp;
      reverse(temp.begin(), temp.end());
      while (temp.size() < 20) temp += "0";
      reverse(temp.begin(), temp.end());
      int mask = 0;
      for (int i = 0; i < temp.size(); i++) {
        mask = mask * 2 + temp[i] % 2;
      }
      if (st == "+")
        cnt[mask]++;
      else
        cnt[mask]--;
    } else {
      string temp;
      cin >> temp;
      reverse(temp.begin(), temp.end());
      while (temp.size() < 20) temp += "0";
      reverse(temp.begin(), temp.end());
      int mask = 0;
      for (int i = 0; i < temp.size(); i++) {
        mask = mask * 2 + temp[i] % 2;
      }
      cout << cnt[mask] << "\n";
    }
  }
  cin.get();
  cin.get();
  return 0;
}
