B. Bob the Builder
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Bob is playing one of his favorite board games, Tiny Towns! Let's look at a simplified version of it.

All gameplay takes place on a grid with $$$r$$$ rows and $$$c$$$ columns. Each cell in this grid can either be empty, or can contain a fountain.

A fountain is considered active if and only if it satisfies the following condition:

  • It is adjacent to another fountain (i.e. the cell it's in shares an edge—not just a corner—with another cell that also has a fountain).
For example, in the following diagram, $$$r=3$$$ and $$$c=5$$$, and circles represent fountains. Active fountains are colored blue.

Bob gets $$$2$$$ points for every active fountain on his board. If he can place one more fountain on the board, and he does so at the optimal spot, what is the maximum score Bob can get?

Input

The first line of input contains the two space-separated integers $$$r$$$ and $$$c$$$.

The description of the grid follows. It consists of $$$r$$$ lines, each containing a string of length $$$c$$$. This encodes the initial state of the grid, where . is an empty cell, and # is a cell with a fountain.

Output

Output a single integer, Bob's maximum score after placing one more fountain on the board, if he does so at the optimal place.

Scoring

$$$$$$\begin{align*}

&\begin{array}{|l|} \hline \text{Constraints For All Subtasks} \\ \hline \text{There is at least one empty cell.} \\ 1 \leq r, c \\ rc \leq 160000 \\ \hline \end{array}\\

&\begin{array}{|c|c|l|} \hline \text{Subtask} & \text{Points} & \text{Constraints} \\ \hline 1 & \mathbf{34} & rc \leq 50 \\ \hline 2 & \mathbf{33} & rc \leq 1600 \\ \hline 3 & \mathbf{33} & \text{No further constraints.} \\ \hline \end{array}\\

\end{align*}$$$$$$

Example
Input
3 5
#.##.
..#.#
#.##.
Output
16
Note

For the sample test case, place the new fountain in the second row from the top, first column from the left. This activates the fountains to its north and south, as well as results in it being active itself.