Жишээ тэстүүд

Оролт
RRLRL
Гаралт
1
2 5 1 3 4
Оролт
RLRLRLRLR
Гаралт
0
1 2 3 4 5 6 7 8 9
Оролт
RRRRRLLLL
Гаралт
4
4 9 3 8 2 7 1 6 5

Тэмдэглэл

For the first sample, one possible order is $2 -> 5 -> 1 -> 3 -> 4$, among them only the step $5 -> 1$ is backward step so the answer is $1$.

For the second example one possible order is just to follow the order of input, thus there are no backward steps.

For the third sample, there will be $4$ backward steps because every step from L to R will be a backward step.