Public Judge

pjudge

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100
Statistiques

Little $w$ and little $b$ are playing a game of Go. Unlike traditional Go, they are playing on a board consisting of $n$ cells arranged in a row, where each cell can hold at most one piece.

Let $S_i$ be the piece in the $i$-th cell from left to right, where $S_i \in \{W, B, \cdot\}$, representing a white piece, a black piece, or an empty cell, respectively.

If there exists an interval $[l, r]$ such that $r - l + 1 \ge 3$ and all cells in this interval are occupied by pieces, and the pieces in cells $l+1, \dots, r-1$ are of the same color, while the pieces in cells $l$ and $r$ are of the opposite color, then the pieces in cells $l+1, \dots, r-1$ are said to be captured. For example, if the board is WWBBW.WB, the pieces in the third and fourth cells are captured.

You are given $S_i$, and it is guaranteed that no pieces are currently captured. It is little $w$'s turn to move, meaning little $w$ must choose an empty cell to place a white piece. The move must be such that no white pieces are captured after placing the piece (it is guaranteed that at least one such move exists).

Little $w$ wants to maximize the number of black pieces captured by his move, but he is not very skilled at the game, so he has asked you to calculate this maximum number for him.

Input

A single line containing a positive integer $n$ and a string of length $n$ consisting of B, W, and . representing $\{S_i\}$.

Output

A single integer representing the maximum number of black pieces that can be captured.

Examples

Input 1

5 .WB..

Output 1

1

Note

We can place a piece in the third cell, which will result in the black piece in the second cell being captured.

Input 2

5 WB.B.

Output 2

0

Note

If we place a piece in the third cell, that piece would be captured, which is not allowed by the rules. Therefore, we can only place a piece in the fifth cell, which does not capture any pieces.

Constraints

For $30\%$ of the data, it is guaranteed that there is exactly one $i$ such that $S_i = B$.

For another $5\%$ of the data, it is guaranteed that $\forall i, S_i \ne W$.

For $100\%$ of the data, it is guaranteed that $1 \le n \le 100$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.