Https://hack.codingblocks.com/contests/c/509/241

i am getting one wrong case with this code

string s;

cin>>s;

int n=s.length();

sort(s.begin(),s.end());

int i,j,cs=1,ms=1;
char ch;
for(i=0;i<n;i++){
    
    if(s[i+1]!=s[i]){
        ms=1;
    }
    else{
        ms++;
    }
    if(ms>cs){
        cs=ms;
    ch = s[i];}
    
}

if(i==n){
    cout<<ch;
}

this code will find the maximum frequency character occuring continuously.
For Example:
INPUT:
bbbbbacacacacacacacacaa
EXPECTED OUTPUT:
a
OUTPUT:
b