An 8×8 chess board is used to play
checkers. Each player starts with 12 normal pieces (“men”) on the black squares
of the three rows closest to their own side. During of the game, the pieces may
only move on unoccupied black squares. The players take turns moving one of the
pieces.
A normal piece can slide diagonally forward
to an adjacent square. Forward direction is defined as the direction toward the
last row, which is the most distant from the player.
A normal piece can capture an opponent's
piece. To do so, the piece is moved two squares diagonally in any direction “jumping
over” the opponent's piece, which is later removed from the board. If the new
position of the jumping piece allows to capture another opponent's piece
(either “man” or “king”) then the move is continued until the jumping piece
reaches the position where capture is not possible. A single opponent's piece
can be jumped over only once during a move. Captured pieces are removed from
the board only when the move is finished.
Jumping is mandatory. When there is more
than one way for a player to jump, one may choose which sequence to make.
Write a program that will analyze the given
checkers position and determine the maximum number of black pieces that can be
captured by white in a single move, assuming there are no “kings” in the game.
Input
The input file consists of 8 lines, 8
characters each. Capital Latin letters “W” are used to denote white pieces, “B”
for black. Empty squares of the board are marked with period characters (“.”).
Output
The output file should contain a single
integer, the maximum number of black pieces that can be captured by white in a
single move, for the given position.
Example
Input
|
Output
|
........
........
.B.B.B..
........
.B.B....
........
.B.B....
W.......
|
6
|
Input
|
Output
|
........
........
.B.B.B..
........
.B.B....
........
...B....
W.......
|
0
|