favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

# Rook, knight and bishop

On the chessboard, bishop, rook and a knight of the same color. How many fields are under the board fight?

Rook (R) runs only on the horizontals and verticals, the knight (N) - two squares in one direction and one to the other (the letter "Г"), bishop (B) - runs along the diagonals. By the way, the knight - the only chess piece that in its course can jump both through itself and the enemy's pieces.

The figure with red dots show the field that are under the gun (in chess terms - under the battle), only the knight, blue - just a rook, green - just an bishop. Yellow dots denote the field under battle knight and rook simultaneously.

Input

In a single line in the international chess notation (see the example input data) are defined by a space position bishop, knight and rook (in any order). All input data is valid.

Output

Derive a single number - the number of checkerboard fields under their "target".

Time limit 1 second
Memory limit 64 MiB
Input example #1
Ne6 Rg7 Bg4

Output example #1
21

Source Stage II All-Ukrainian Olympiad 2010-2011 Berdichev