The bishop and pawn against the bishop#309

The bishop and pawn against the bishop

1 second
64 megabytes
Hard

In a chess game, Petryk, playing as White, reached an endgame with a bishop and a pawn against a bishop. Petryk read somewhere that such endgames are very difficult to win, so he decided to write a program to help him analyze the position. To begin, Petryk needs to determine how many possible options he has to analyze on White's first move, i.e., count how many moves White has that are allowed by the rules of chess. In this problem, promotion of the pawn to any piece is considered as a single move. Write a program that can do this.

Input

The first line contains the positions of the White pieces, separated by spaces: the king, the bishop, and the pawn, respectively. The second line contains the positions of the Black king and bishop. Piece notation is the same as that used in international chess notation.

Output

A single number — the answer to Petryk's question.

Examples

Example 1

Loading
Loading