int isValid(string s) {
stack<char> st;
for(char c : s){
if(st.empty()){
st.push(c);
}else if(c - st.top() == 1||c - st.top() == 2){
st.pop();
}else{
st.push(c);
}
}
return st.empty()? s.length()/2:-1;
}