Hey, here is a code that gets AC. ubdt9G - Online C++ Compiler & Debugging Tool - Ideone.com
For instance, if we are considering n = |s| then answer is non zero according to the formula. In all other cases the formula works good. I’ve hard coded the answer for n = |s| cases. Please attach some example if you think i missed your point.