#include <bits/stdc++.h>
using namespace std;
long long int fun(long long int p, string str) {
  string s = to_string(p);
  long long int i = str.length() - 1, j = s.length() - 1;
  for (; i >= 0 && j >= 0; i--, j--) {
    if (str[i] == '0' && ((s[j] - '0') % 2) != 0)
      return 0;
    else if (str[i] == '1' && ((s[j] - '0') % 2 == 0))
      return 0;
  }
  p = str.length();
  long long int q = s.length();
  if (p > q) {
    while (i >= 0) {
      if ((str[i] - '0') % 2 != 0) return 0;
      i--;
    }
  } else if (q > p) {
    while (j >= 0) {
      if ((s[j] - '0') % 2 != 0) return 0;
      j--;
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  cin >> t;
  map<string, int> mp;
  while (t--) {
    char ch;
    cin >> ch;
    string str;
    cin >> str;
    for (int i = 0; i < str.length(); i++) {
      if ((str[i] - '0') % 2 == 0)
        str[i] = '0';
      else
        str[i] = '1';
    }
    while (str.length() < 18) str = "0" + str;
    if (ch == '+') {
      mp[str]++;
    } else if (ch == '-') {
      mp[str]--;
    } else {
      cout << mp[str] << '\n';
    }
  }
}
