class Solution {
public int solution(String s) {
int answer = 0;
char [] c = s.toCharArray();
char f = c[0];
int count1 = 0;
int count2 = 0;
int i = 0;
int len = c.length;
String sub = null;
for(i=0; i<len; i++){
if(c[i]==f)
count1++;
else
count2++;
if(count1==count2)
break;
}
if(count1==count2 ){
if(i< len-1)
sub = s.substring(i+1,len);
else
return 1;
}
if(count1!=count2 && i==len)
return 1;
return solution(sub)+1;
}
}