class Solution {
public:
int balancedStringSplit(string s) {
int cnt = 0;
int res = 0;
for(auto &ch : s){
if(ch == 'R'){
cnt++;
}else if(ch == 'L'){
cnt--;
}
if(cnt == 0){
res++;
}
}
return res;
}
};