Jafar is playing checkers with his friend Aladdin. Checkers is a board game in which both players take turns to move their pawns. Jafar has just one pawn left, and he is going to take a final turn, beating as many of Aladdin's pawns as possible.
Pawns in checkers move diagonally. The pawn always moves one step in the up-right or up-left direction. If Jafar's pawn moves and its target field is occupied by one of Aladdin's pawns, Aladdin's pawn can be beaten: Jafar's pawn leaps over Aladdin's pawn, taking two steps in the chosen direction and removing Aladdin's pawn from the board. Jafar can beat Aladdin's pawn in this way only when the field beyond Aladdin's pawn is empty.
After beating Aladdin's pawn, Jafar can continue his turn and make another move, but only if he will again beat another one of Aladdin's pawns. Of course, after this additional move, Jafar can continue his turn again by beating another of Aladdin's pawns, and so on for as long as there are further pawns to beat. When it is no longer possible to beat one of Aladdin's pawns, Jafar's turn ends.
For example, in the situation depicted below (where Jafar's pawn is white and Aladdin's pawns are black):

Jafar can beat one of Aladdin's pawns by moving his pawn two steps in the up-right direction, and then he can make an additional move, beating another of Aladdin's pawns in the up-left direction. After this move there are no more of Aladdin's pawns available to beat, so Jafar's turn ends.
In the following situations:

Jafar cannot beat Aladdin's pawn. In the first case, the field two steps in the up-right direction from Jafar's pawn (white) is occupied by one of Aladdin's pawns (black); in the second case, this field is placed outside the board; in the third case, Jafar's pawn cannot move directly upwards; and finally, in the fourth case, Jafar's pawn cannot move in the down-right direction.
**What is the maximum number of pawns owned by Aladdin that Jafar can beat in his turn?
**
Write a function:
int solution(char *B[], int N);
which, given a square board of N x N size describing Aladdin's and Jafar's pawns, returns the maximum number of pawns Jafar can beat in one turn. If none of Aladdin's pawns can be beaten, the function should return 0.
Jafar's pawn is described by the 'O' character, Aladdin's pawns by 'X' characters and empty fields by '.' (dots). The board is described from top to bottom and from left to right.
For example, given:
B[0] = "..X..."
B[1] = "......"
B[2] = "....X."
B[3] = ".X...."
B[4] = "..X.X."
B[5] = "...O.."
the function should return 2 (Jafar can beat Aladdin's pawn in the up-right direction and then another one in the up-left direction).
Given:
B[0] = "X...."
B[1] = ".X..."
B[2] = "..O.."
B[3] = "...X."
B[4] = "....."
the function should return 0.
Assume that: