CF2204A.Passing the Ball

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Passing the Ball

During a physical education class, nn students are lined up, numbered from 11 to nn from left to right.

For each student, it is known that if they receive the ball, they will pass it either to the neighbor on their left or to the neighbor on their right. This is specified by a string ss of nn characters. Each character of the string is either L or R, where sis_i is L if the ii-th student passes the ball to student (i1)(i-1), or sis_i is R if the ii-th student passes the ball to student (i+1)(i+1). The first student always passes the ball to the second, and the last one to the second last (in other words, the string ss starts with the character R and ends with the character L).

Consider the following process:

  • first, the first student receives the ball;
  • then, exactly nn times, the following occurs: the student who currently has the ball passes it to their neighbor (according to the rules described above).

Your task is to determine how many students will receive the ball at least once during this process.

Input

The first line contains a single integer tt (1t100001 \le t \le 10000) — the number of test cases.

Each test case consists of two lines:

  • the first line contains a single integer nn (2n502 \le n \le 50) — the number of students;
  • the second line contains ss — a sequence of nn characters L and R. The first character of the sequence is R, and the last is L.

Output

For each test case, print one integer — the number of students who will receive the ball at least once during the described process.

Note

In the first example, student 11 receives the ball and passes it to student 22, who returns it back to student 11, who passes it back to student 22, and so on. Only students 11 and 22 received the ball.

In the second example, student 11 passes the ball to student 22, who passes it to student 33, who passes it to student 44, who passes it to student 55, who passes it to student 66, who returns it to student 55. Each student received the ball at least once.

Samples

3
4
RLRL
6
RRRRRL
9
RRLRRRRRL
2
6
3

在线编程 IDE

建议全屏模式获得最佳体验