#include <bits/stdc++.h>
using namespace std;
multiset<long long> ms[1111111];
int findIndex(long long x) {
  int ret = 0;
  for (int i = 0; i < 20; i++) {
    if (x % 2)
      ret = 2 * ret + 1;
    else
      ret = 2 * ret;
    x /= 10;
  }
  return ret;
}
int main() {
  int t;
  scanf("%d", &t);
  for (int query = 0; query < t; query++) {
    char type;
    long long x;
    scanf(" %c", &type);
    scanf("%lld", &x);
    int index = findIndex(x);
    if (type == '+')
      ms[index].insert(x);
    else if (type == '-') {
      auto it = ms[index].find(x);
      ms[index].erase(it);
    } else
      printf("%d\n", (int)ms[index].size());
  }
  return 0;
}
