Chessboard 2

Place as many non-overlapping L-trominoes as possible on a grid with blocked cells, with each tile's corner on a black square.

Hard8GraphBit manipulationDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

Donghyuk has a rectangular chessboard. Its rows and columns are numbered from 0. The cell in row ii and column jj is black when i+ji+j is even and white when i+ji+j is odd. Some cells of the board hold a piece.

Yunho has a very large supply of L-shaped tiles. One tile is three squares, each the size of a board cell, joined as in the picture below.

OO
O

Yunho wants to lay tiles on the board under the following rules.

  • A tile can be rotated by 90, 180, or 270 degrees.
  • One tile must cover three cells of the board.
  • Two tiles must not overlap.
  • A tile cannot cover a cell that holds a piece.
  • The corner cell of a tile, the one that touches both of the other two squares, must cover a black cell.

Write a program that finds the largest number of tiles Yunho can lay.

Input

The first line contains the number of rows RR and the number of columns CC of the board. (1R471 \le R \le 47, 1C471 \le C \le 47)

Each of the next RR lines contains one row of the board as a string of length CC. 'X' is a cell that holds a piece and '.' is an empty cell.

Output

Print the largest number of tiles Yunho can lay.