시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB36312395.833%

문제

On his birthday party, Glen wants to play the most exciting game. It is called Splash Game. For this, his parents built a bridge, which goes over the full length of the family pool and can be seen as a $2 \times n$ grid: it consists of $n$ steps and at each step, there are two plates. The players go over the bridge one after the other in a fixed order. At each of the $n$ steps, one of the two plates is fake and the player will fall into the pool with a big Splaaaaash when she steps onto it.

Of course, a participant can be lucky and guess the real plate and will not fall (she might still fall later). Also the first player really has a tough time. To make it to the other side, she would need to guess the real plate at every step. The later players have the advantage that they can see what the others are doing and hence know for the already entered steps, which plate is the real one (if a player guesses the real plate, everybody sees it; if she guesses the fake one and falls, everybody knows that the other plate is the real one).

The players proceed by a simple strategy. The first player starts by choosing the left plate on the first step. If she is correct, she switches to the right side and she will keep switching the side at every step (it is common knowledge that switching is a good idea). Every other player, once it is her turn, follows the correct choices as far as they are known and, afterwards, applies the switching strategy as well, i, e., if she stepped on the left plate on the previous step, she now steps on the right one and vice versa.

Of course, the game is only fun if at least a few kids make it to the other side of the bridge. But it shouldn't be too many either, since everybody has a great laugh when somebody is falling into the water. Given the number of kids and the planned layout of fake and real plates, output how many kids make it to the other side of the bridge.

Figure K.1: The bridge layout for Sample Input 4 (cracked squares indicate the fake plates). The first player will guess the first step correctly, but fall on the second step. The second player thus knows the correct choices for the first two steps and guesses the third and fourth one correctly by switching. In the end, three of the seven kids make it to the other side.

입력

The input consists of:

  • One line with integers $n, k$ ($1 \leq n,k \leq 10^3$), the length of the bridge and the number of kids.
  • One string $s$ of length $n$ consisting of characters L and R. An L on position $i$ indicates that the real plate at step $i$ is the left one, an R indicates the right plate is the real one.

출력

Output a single integer, the number of kids who make it to the other side of the bridge.

예제 입력 1

3 5
LRL

예제 출력 1

5

예제 입력 2

3 2
RRR

예제 출력 2

0

예제 입력 3

3 5
LLL

예제 출력 3

3

예제 입력 4

8 7
LLRLLLRR

예제 출력 4

3

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2022 K번

  • 문제를 만든 사람: Marcel Wienöbst