e-olymp
Problems

Knicht and pawn against a Knicht

Knicht and pawn against a Knicht

prb308

Horse and pawn against a horse to you the certain correct postponed chess party in which there was a termination a horse and a pawn against a horse is set. As always, in the postponed position a course white.

Your problem is very simple - to define quantity of possible courses of a white horse. Possible courses by rules are shown in figure by red points.

Input

In the first line the arrangement of white figures, and in the second - black is set through a blank. Designations of figures are given below in the note.

Output

To deduce a singular - required quantity of admissible courses of a white horse.

Time limit 1 second
Memory limit 64 MiB
Input example
Ke2 Nc4 b3
Kh7 Nf6
Output example
8

Example description: K - King N - Knicht