#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:67108864")
const int MOD = 1000000007;
const long long INF = 3000000000000000001;
const double EPS = 1e-6;
const int HASH_POW = 29;
const double PI = acos(-1.0);
using namespace std;
double workTime() { return double(clock()) / CLOCKS_PER_SEC; }
void my_return(int code) { exit(code); }
int cnt[1000000];
void add(string s) {
  reverse(s.begin(), s.end());
  int len = s.length();
  int ptr = 0;
  for (int i = 0; i < 18; ++i) {
    int bit;
    if (i < len)
      bit = (s[i] - '0') % 2;
    else
      bit = 0;
    ptr += bit * (1 << i);
  }
  ++cnt[ptr];
}
void destroy(string s) {
  reverse(s.begin(), s.end());
  int len = s.length();
  int ptr = 0;
  for (int i = 0; i < 18; ++i) {
    int bit;
    if (i < len)
      bit = (s[i] - '0') % 2;
    else
      bit = 0;
    ptr += bit * (1 << i);
  }
  --cnt[ptr];
}
int count(string s) {
  reverse(s.begin(), s.end());
  int len = s.length();
  int ptr = 0;
  for (int i = 0; i < 18; ++i) {
    int bit;
    if (i < len)
      bit = (s[i] - '0') % 2;
    else
      bit = 0;
    ptr += bit * (1 << i);
  }
  return cnt[ptr];
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  mt19937 mt_rand(time(0));
  int q;
  cin >> q;
  while (q--) {
    char c;
    string v;
    cin >> c >> v;
    if (c == '+')
      add(v);
    else if (c == '-')
      destroy(v);
    else if (c == '?')
      cout << count(v) << endl;
    else
      return 1;
  }
  my_return(0);
}
