Codeforces Round 238 (Div. 2)
B
Domino Effect
Codeforces
1100
原题
← AC →
翻译中…

Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".

翻译中…

Chris arranges $*n*$ dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the dominoes either to the left or to the right. However, somewhere between every two dominoes pushed in the same direction there is at least one domino pushed in the opposite direction.

翻译中…

After each second, each domino that is falling to the left pushes the adjacent domino on the left. Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right. When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces. The figure shows one possible example of the process.

翻译中…

image

翻译中…

Given the initial directions Chris has pushed the dominoes, find the number of the dominoes left standing vertically at the end of the process!

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ ($1 ≤ *n* ≤ 3000$), the number of the dominoes in the line. The next line contains a character string $*s*$ of length $*n*$. The $*i*$-th character of the string $*s*_{*i*}$ is equal to

翻译中…
  • "L", if the $*i*$-th domino has been pushed to the left;
  • "R", if the $*i*$-th domino has been pushed to the right;
  • ".", if the $*i*$-th domino has not been pushed.
翻译中…

It is guaranteed that if $*s*_{*i*} = *s*_{*j*} =$"L" and $*i* < *j*$, then there exists such $*k*$ that $*i* < *k* < *j*$ and $*s*_{*k*} =$"R"; if $*s*_{*i*} = *s*_{*j*} =$"R" and $*i* < *j*$, then there exists such $*k*$ that $*i* < *k* < *j*$ and $*s*_{*k*} =$"L".

翻译中…

Output

翻译中…

Output a single integer, the number of the dominoes that remain vertical at the end of the process.

翻译中…

Note

翻译中…

The first example case is shown on the figure. The four pieces that remain standing vertically are highlighted with orange.

翻译中…

In the second example case, all pieces fall down since the first piece topples all the other pieces.

翻译中…

In the last example case, a single piece has not been pushed in either direction.

翻译中…

样例

Input #1
14
.L.R...LR..L..
Output #1
4
InputCopy OutputCopy
Input #2
5
R....
Output #2
0
InputCopy OutputCopy
Input #3
1
.
Output #3
1
InputCopy OutputCopy
题目信息
题号
405B
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。