시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 31 12 12 41.379%

문제

Purple rain falls in the magic kingdom of Linearland which is a straight, thin peninsula.

On close observation however, Professor Nelson Rogers finds that the purple rain is actually a mix of red and blue raindrops.

In his zeal, he records the location and color of the raindrops in different locations along the peninsula. Looking at the data, Professor Rogers wants to know which part of Linearland had the “least” purple rain.

After some thought, he decides to model this problem as follows. Divide the peninsula into n sections and number them west to east from 1 to n. Then, describe the raindrops as a sequence of R and B, depending on whether the rainfall in each section is primarily red or blue. Finally, find a subsequence of contiguous sections where the difference between the number of R and the number of B is maximized.

입력

The input consists of a single line containing a string of n characters (1 ≤ n ≤ 105), describing the color of the raindrops in sections 1 to n.

It is guaranteed that the string consists of uppercase ASCII letters ‘R’ and ‘B’ only.

출력

Print, on a single line, two space-separated integers that describe the starting and ending positions of the part of Linearland that had the least purple rain. These two numbers should describe an inclusive range; both numbers you print describe sections included in the range.

If there are multiple possible answers, print the one that has the westernmost starting section. If there are multiple answers with the same westernmost starting section, print the one with the westernmost ending section.

예제 입력 1

BBRRBRRBRB

예제 출력 1

3 7

예제 입력 2

BBRBBRRB

예제 출력 2

1 5