#P11752. [COCI 2024/2025 #5] 挂画 / Zid

[COCI 2024/2025 #5] 挂画 / Zid

Description

Mr. Malnar wants to put up a picture of himself on the wall. The wall can be represented as a matrix with nn rows and mm columns. Since he has placed his picture on the wall many times before, some positions still have nails embedded in them. Such positions are marked with the symbol "#\texttt{\#}", while empty spots are marked with the symbol ".\texttt{.}".

The picture has a rectangular shape with arbitrary dimensions and is placed on the wall in a way that it covers a rectangular area. The picture can be placed on the wall if it covers at most one position that contains a nail.

Help Mr. Malnar calculate the number of ways he can place his picture on the wall.

Input Format

The first line of input contains nn and mm (1n,m5001 ≤ n,m ≤ 500), the dimensions of the wall.

In each of the next nn lines, there are mm characters cijc_{ij} , describing the wall. Each character will be either ".\texttt{.}" or "#\texttt{\#}" (without quotes).

Output Format

In a single line of output, print the number of possible ways to place the picture on the wall.

3 3
...
...
..#
36
4 4
....
.#..
#...
#.#.
76
5 5
.....
#..#.
..#.#
.....
..#..
154

Hint

Clarification of the first example:

Each placement of the picture is valid as long as it covers at most one nail.

Clarification of the second example:

The picture cannot be placed in a way that it covers positions (3,1)(3, 1) and (4,1)(4, 1) simultaneously.

Scoring

Subtask Points Constraints
11 1717 n,m10n,m ≤ 10
22 2121 n,m100n,m ≤ 100
33 3232 No additional constraints.