The bishop and pawn against the bishop

The bishop and pawn against the bishop


In one of chess parties at Piters, played white, there was a termination the bishop and a pawn against the bishops. Piter somewhere read, that such terminations are very difficult for winning and consequently has decided to write the program which would help it to analyse the arisen position.

For the beginning Piters it is necessary to define, how many possible variants it needs to analyze on the first to a course white, i.e. to count, how many at white is courses admissible by chess rules. Transformation of a pawn into any figure into this problem to consider as one course.

Write the program which is able to do it.


In the first line of entrance data the arrangement of white figures is set through a blank: king, bishop and a pawn accordingly. In the second line - an arrangement of king and bishop black. The designation of figures is used same as it is accepted in the international chess notation.


Singular number - the answer on put Piters a problem.

Time limit 1 second
Memory limit 64 MiB
Input example #1
Ke2 Be5 b3
Kh7 Be7
Output example #1