#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long base = 1e9 + 7;
const int N = 1e5 + 2;
long long n;
map<long long, long long> d;
long long a[N];
char c;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = (1), b_ = (n); i <= b_; ++i) {
    cin >> c >> s;
    if (c == '+') {
      long long t = 1;
      long long k = 0;
      for (int i = (0), b_ = (s.size() - 1); i <= b_; ++i)
        a[i] = (s[i] - '0') % 2;
      for (int i = (s.size() - 1), b_ = (0); i >= b_; --i) {
        if (a[i] == 1) {
          k += t;
        }
        t *= 2;
      }
      d[k]++;
    } else if (c == '-') {
      long long t = 1;
      long long k = 0;
      for (int i = (0), b_ = (s.size() - 1); i <= b_; ++i)
        a[i] = (s[i] - '0') % 2;
      for (int i = (s.size() - 1), b_ = (0); i >= b_; --i) {
        if (a[i] == 1) {
          k += t;
        }
        t *= 2;
      }
      d[k]--;
    } else {
      long long t = 1;
      long long k = 0;
      for (int i = (0), b_ = (s.size() - 1); i <= b_; ++i)
        a[i] = (s[i] - '0') % 2;
      for (int i = (s.size() - 1), b_ = (0); i >= b_; --i) {
        if (a[i] == 1) k += t;
        t *= 2;
      }
      cout << d[k] << endl;
    }
  }
  return 0;
}
