5722: 效应

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:5 通过:3

题目描述

  小克里斯知道玩多米诺骨牌没有乐趣,他认为这太随机了,不需要技巧。相反,他决定玩多米诺骨牌,做一个“多米诺骨牌秀”。
克里斯将n张多米诺骨牌排成一条线,将每张多米诺骨牌垂直直立放置。一开始,他同时将一些多米诺骨牌推向左边或右边。然而,在每两张多米诺骨牌向同一方向推的某个地方,至少有一张多米诺骨牌被推向相反的方向。

每一秒后,每张落在左边的多米诺骨牌都会把相邻的多米诺骨牌推到左边。同样,倒在右边的多米诺骨牌会推站在右边的相邻多米诺骨牌。当垂直多米诺骨牌的多米诺骨牌从两侧落在上面时,由于力量的平衡,它会保持静止。该图显示了该过程的一个可能示例。

鉴于克里斯推动多米诺骨牌的初始方向,找出在过程结束时垂直站立的多米诺骨牌数量!


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.
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 si 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 si=sj="L" and i<j, then there exists such k that i<k<j and sk="R"; if si=sj="R" and i<j, then there exists such k that i<k<j and sk="L".
Output
Output a single integer, the number of the dominoes that remain vertical at the end of the process.
Examples
Input
14
.L.R...LR..L..
Output
4
Input
5
R....
Output
0
Input
1
.
Output
1
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.

输入格式

第一行包含一个整数 n (1≤n≤3000),即行中多米诺骨牌的数量。下一行包含长度为 n 的字符串 s。字符串 si 的第 i 个字符等于
“L”,如果第 i 张多米诺骨牌被推到左侧;
“R”,如果第 i 张多米诺骨牌被推到右侧;
“.”,如果第 i 张多米诺骨牌没有被推。
可以保证,如果 si=sj=“L” 和 i<j,则存在这样的 k,即 i<k<j 和 sk=“R”;如果 si=sj=“R” 和 i<j,则存在这样的 k,即 i<k<j 和 sk=“L”。

输出格式

输出单个整数,即在进程结束时保持垂直的多米诺骨牌的数量。

输入样例 复制

14
.L.R...LR..L..

输出样例 复制

4

数据范围与提示

Input
14
.L.R...LR..L..
Output
4
Input
5
R....
Output
0
Input
1
.
Output
1
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.