Missing edge cases

hey can you see what seems to be the problem with the code

@pradyumn25jain
Your code will fail on test cases like : 2
bbbaaabbbab

Your program gives output 9 whereas correct answer is 6.
try to dry run