#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5;
int a[MAX] = {};
int main() {
  int t;
  cin >> t;
  while (t--) {
    char c;
    long long s;
    cin >> c >> s;
    long long a1 = 0;
    for (int i = 0; i < 18; i++) {
      a1 = a1 * 2 + s % 2;
      s /= 10;
    }
    if (c == '+') {
      a[a1]++;
    } else if (c == '-') {
      a[a1]--;
    } else {
      cout << a[a1] << "\n";
    }
  }
  return 0;
}
