

The first line contains an integer ‘T’ denoting the number of test cases. Then each test case follows.
The first input line of each test case contains the string ‘S’ denoting the given string.
For each test case, print an integer denoting the maximum amount of split balanced strings possible.
Print the output of each test case in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= |S| <= 10000
Where S[i] is either ‘L’ or ‘R’ and '|S|' is the length of the given string.
Time limit: 1 sec
The basic idea of this approach is to iterate through the string while maintaining a variable “balance” which is initially equal to 0. Whenever we encounter ‘L we will increment the “balance” variable and similarly, whenever we encounter ‘R’ we will decrement it.
Now, let’s see an example where input string S = “LRRLRL”. Start iterating the string using a variable ‘j’.
We observe from the above explanation that the number of times the “balance” variable becomes 0 is the maximum amount of split balanced strings possible.
The steps are as follows: