Marathon weekend with restrictions
Queen, rook and bishop
On the chessboard, the queen, rook and bishop of the same color. How many fields are under the board fight?
Rook (R) runs only on the horizontals and verticals, the Bishop (B) - only on the diagonals, Queen (Q) - goes on horizontals, verticals and diagonals.
The figure with red dots show the field that are under the gun (in chess terms - under the battle), only the queen, blue - just a rook, green - just an bishop. Yellow dots denote the field under battle queen and rook at the same time, brown - the queen and bishop at the same time, the blue dot denotes the field to the fight while under the bishop and the rook.
In a single line in the international chess notation (see the example input data) are defined by a space position queen, rook and bishop (in no particular order). All input data is valid.
Derive a single number - the number of checkerboard fields under their "target".
Qe5 Rg7 Bg4