#include <bits/stdc++.h>
using namespace std;
struct node {
  int endmark;
  node *next[28];
  node() {
    endmark = 0;
    for (int i = 0; i < 2; i++) next[i] = NULL;
  }
} * root;
void insert(string str, int len) {
  node *cur = root;
  for (int i = 0; i < len; i++) {
    int id = str[i] - '0';
    if (cur->next[id] == NULL) {
      cur->next[id] = new node();
    }
    cur = cur->next[id];
  }
  cur->endmark++;
  return;
}
void del(string str, int len) {
  node *cur = root;
  for (int i = 0; i < len; i++) {
    int id = str[i] - '0';
    cur = cur->next[id];
  }
  cur->endmark--;
  return;
}
int solve(string str, int len) {
  node *cur = root;
  for (int i = 0; i < len; i++) {
    int id = str[i] - '0';
    if (cur->next[id] == NULL) {
      return 0;
    }
    cur = cur->next[id];
  }
  return cur->endmark;
}
int main() {
  int Q;
  cin >> Q;
  root = new node();
  while (Q--) {
    char ch;
    cin >> ch;
    if (ch == '+') {
      long long a;
      cin >> a;
      string s;
      s.resize(18);
      for (int i = 0; i < 18; i++) {
        long long dig = a % 10;
        if (dig % 2 == 0)
          s[i] = '0';
        else
          s[i] = '1';
        a = a / 10;
      }
      insert(s, s.size());
    } else if (ch == '-') {
      long long a;
      cin >> a;
      string s;
      s.resize(18);
      for (int i = 0; i < 18; i++) {
        long long dig = a % 10;
        if (dig % 2 == 0)
          s[i] = '0';
        else
          s[i] = '1';
        a = a / 10;
      }
      del(s, 18);
    } else {
      string s;
      cin >> s;
      string t;
      t.resize(18);
      for (int i = s.size() - 1, j = 0; i >= 0; i--, j++) {
        t[j] = s[i];
      }
      for (int i = s.size(); i < 18; i++) t[i] = '0';
      int ans = solve(t, 18);
      cout << ans << endl;
    }
  }
}
