문제
Farmer John, desperate to win the award for best cow photographer at the county fair, is trying to take the perfect photograph of his cows (, even).
Farmer John owns cows of two potential breeds: Guernseys and Holsteins.
To make his photo as aesthetic as possible, he wants to line up his
cows so that as many Guernseys are in even-numbered positions in the line
as possible (the first position in the line is an odd position, the next is
an even position, and so on). Due to his lack of strong
communication with his cows, the only way he can achieve his goal is by asking
even length "prefixes" of his cows to reverse themselves (a prefix
consists of the range of cows from the first cow up to the th cow
for some position ).
Please count the minimum number of reversals required for Farmer John to achieve his goal.
입력
The first line of input contains the value of .
The second line contains a string of length specifying the initial ordering of the cows from left to right. Each 'H' represents a Holstein, while each 'G' represents a Guernsey.
출력
Output the minimum number of reversals needed on a single line.
예제 입력 1
14
GGGHGHHGHHHGHG
예제 출력 1
1
점수
Test cases 2-6 satisfy .Test cases 7-11 satisfy no additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인