#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
struct tire {
  int num;
  tire *next[2];
  tire() {
    num = 0;
    for (int i = 0; i <= 1; i++) {
      next[i] = NULL;
    }
  }
};
void build(tire *p, long long y, int t) {
  int h = 0;
  while (y) {
    int x = y % 10;
    y = y / 10;
    h += 1;
    x = x & 1;
    if (p->next[x] == NULL) p->next[x] = new tire();
    p = p->next[x];
  }
  for (int i = h + 1; i <= 20; i++) {
    if (p->next[0] == NULL) p->next[0] = new tire();
    p = p->next[0];
  }
  p->num += t;
}
void delete_tire(tire *p) {
  for (int i = 0; i < 2; i++)
    if (p->next[i]) delete_tire(p->next[i]);
  delete p;
}
int query(tire *p, long long y) {
  int h = 0;
  while (y) {
    int x = y % 10;
    y = y / 10;
    h += 1;
    x = x & 1;
    if (p->next[x] == NULL) return 0;
    p = p->next[x];
  }
  for (int i = h + 1; i <= 20; i++) {
    if (p->next[0] == NULL) return 0;
    p = p->next[0];
  }
  return p->num;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    long long x;
    char c;
    tire *root = new tire();
    for (int i = 1; i <= n; i++) {
      scanf(" %c %I64d", &c, &x);
      if (c == '+')
        build(root, x, 1);
      else if (c == '-')
        build(root, x, -1);
      else {
        printf("%d\n", query(root, x));
      }
    }
    delete_tire(root);
  }
  return 0;
}
