Another Wine Tasting Event
시간 제한0.5초메모리 제한1024 MB
길이 2n-1인 와인 문자열이 주어질 때, 길이가 n 이상인 n개의 서로 다른 구간이 모두 정확히 같은 수의 흰 와인을 포함하도록 하는 x를 구한다.
문제
After the first successful edition, Gabriella has been asked to organize a second wine tasting event. There will be bottles of wine arranged in a row, each of which is either red wine or white wine.
This time, Gabriella has already chosen the type and order of all the bottles. The types of the wines are represented by a string of length . For each , it holds that R if the -th bottle is red wine, and W if the -th bottle is white wine.
Exactly critics have been invited to attend. The critics are numbered from to . Just like last year, each critic wants to taste an interval of wines, that is, the bottles at positions for some . Moreover, they have the following additional requirements:
- each of them wants to taste at least wines, that is, it must hold that ;
- no two critics must taste exactly the same wines, that is, if it must hold that or .
Gabriella knows that, since the event is held in a coastal region of Italy, critics are especially interested in the white wines, and don’t care much about the red ones. (Indeed, white wine is perfect to accompany seafood.) Thus, to ensure fairness, she would like that all critics taste the same number of white wines.
Help Gabriella find an integer (with ) such that there exists a valid assignment of intervals to critics where each critic tastes exactly white wines. It can be proved that at least one such always exists.
입력
The first line contains the integer () — where is the number of bottles, and is the number of critics.
The second line contains a string s of length that represents the arrangement of the wines — the -th character of () is R for a red wine and W for a white wine.
출력
Print an integer — the number of white wines that each critic will taste.
It can be proved that at least one solution exists. If multiple solutions exist, any of them will be accepted.