#K64952. Taco's Balanced Substrings Count

    ID: 32089 Type: Default 1000ms 256MiB

Taco's Balanced Substrings Count

Taco's Balanced Substrings Count

Given a string consisting solely of the characters R and L, determine the number of balanced substrings. A balanced substring is defined as a substring that contains an equal number of R's and L's. This problem requires partitioning the string into the maximum number of balanced substrings possible.

The input is provided via stdin and the result should be output to stdout as a single integer.

inputFormat

The input consists of a single line containing a string s made up only of the characters R and L.

outputFormat

Output a single integer representing the number of balanced substrings found in the string.

## sample
RLRRLLRLRL
4