Sanket and Strings Problem

Hey! After a lot tries I wrote this code but this is only able to pass the first case, can you please correct this code.

for test case
2
abbbababbaba

answer should be 8 not 7
debug for this

Can You please suggest what is to be done? Iā€™m not able to figure out. Thanks

https://ide.codingblocks.com/s/362221 This is my solution

while(right+1<s.length() && s.charAt(right+1) == c)

line 15