#include <iostream>
#include <map>
using namespace std;
map <int, int> mp;
int main(){
int t;
scanf("%d", &t);
while (t--){
string op, str;
cin>>op>>str;
int x = 0;
for (int i = 0; i < str.length(); i ++ ){
x = x * 2 + (str[i] - '0')%2;
}
if (op == "+"){
mp[x] ++ ;
}
else if (op == "-"){
mp[x] -- ;
}
else {
cout<<mp[x]<<endl;
}
}
}