Sanket_and_strings prob

sample test case is passing but it is showing wrong answer in all other test case. what is wrong with the code?

Hi
2
abaa
This gives me 5, this is the issue.Could you please dry run your code once and fix this?