#ABC274G. [ABC274G] Security Camera 3

[ABC274G] Security Camera 3

Score : 600600 points

Problem Statement

There is a grid with HH rows from top to bottom and WW columns from left to right. Let (i,j)(i, j) denote the square at the ii-th row from the top and jj-th column from the left. Square (i,j)(i, j) is occupied by an obstacle if Si,j=S_{i,j}= #, and is empty if Si,j=S_{i,j}= ..

Takahashi will install some surveillance cameras in the grid.

A surveillance camera can be placed at a square without an obstacle, in one of the four directions: up, down, left, or right. Multiple surveillance cameras may be placed at the same square.

Each surveillance camera monitors the square it is placed at, and the squares in the direction it is placed in, as far as there is no obstacle in between.

At least how many surveillance cameras are needed to monitor all squares without an obstacle?

Constraints

  • 1H,W3001 \leq H,W \leq 300
  • Si,jS_{i,j} is . or #.

Input

The input is given from Standard Input in the following format:

HH WW

S1,1S1,WS_{1,1}\ldots S_{1,W}

\vdots

SH,1SH,WS_{H,1}\ldots S_{H,W}

Output

Print the answer.

3 3
...
.#.
...
4

For example, if we install two surveillance cameras at square (1,1)(1, 1) facing right and down, and another two at square (3,3)(3, 3) facing up and left, all squares without an obstacle will be monitored.

3 5
...##
.#...
...#.
5

For example, if we install two surveillance cameras at square (1,1)(1, 1) facing right and down, another at square (3,3)(3, 3) facing left, and another two at square (2,5)(2, 5) facing left and down, all squares without an obstacle will be monitored.

Note that the camera at square (2,5)(2, 5) facing left cannot monitor square (2,1)(2, 1), since there is an obstacle in between at square (2,2)(2, 2).

14 107
...........................................................................................................
...........................................................................................................
..#########..###....###########..###.......###...###########..####.......###...###########...###########...
..########..###....###########....###.....###...###########...#####......###..###########...###########....
..#######..###.....###.............###...###....###...........######.....###..###...........###............
..######..###......###..............###.###.....###...........###.###....###..###...........###............
..#####..###.......############......#####......############..###..###...###..###...........############...
..####....###......############.......###.......############..###...###..###..###...........############...
..###......###.....###................###.......###...........###....###.###..###...........###............
..##........###....###................###.......###...........###.....######..###...........###............
..#..........###...############.......###.......############..###......#####..############..############...
..............###...###########.......###........###########..###.......####...###########...###########...
...........................................................................................................
...........................................................................................................
91