#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4e5 + 5;
const int MOD = 1e9 + 7;
const int ze = 2e5;
map<int, int> mp;
int main() {
  int N;
  while (~scanf("%d", &N)) {
    mp.clear();
    for (int i = 1; i <= N; ++i) {
      char a[20], b[20];
      scanf("%s %s", a, b);
      int tt = 0;
      for (int j = 0; b[j]; ++j) {
        if ((b[j] - '0') % 2)
          tt = tt * 2 + 1;
        else
          tt = tt * 2;
      }
      if (a[0] == '+') {
        mp[tt]++;
      } else if (a[0] == '-') {
        mp[tt]--;
      } else {
        printf("%d\n", mp[tt]);
      }
    }
  }
  return 0;
}
