#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int INF = 1e9 + 9;
const int MOD = 1e9 + 7;
string c, s;
int t;
map<long long, long long> m;
int main() {
  cin >> t;
  for (int i = 1, _b = (t); i <= _b; i++) {
    cin >> c >> s;
    int d = 0;
    for (int i = 0, _b = (s.size() - 1); i <= _b; i++)
      d = d * 10 + (s[i] - '0') % 2;
    if (c == "+") m[d]++;
    if (c == "-") m[d]--;
    if (c == "?") cout << m[d] << endl;
  }
}
