<>=~s#|.#$\+=$-=2*y!\0!!-$\+$|--for$'^reverse$`#ger;print