Problem list
Log in
#coci00732 · COCI 2024/2025 Contest 5

Zid

Gold I 1.0 s 512 MB

Mr. Malnar wants to put up a picture of himself on the wall. The wall can be represented as a matrix with $n$ rows and $m$ 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 "#", while empty spots are marked with the symbol ".". 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

The first line of input contains $n$ and $m$ ($1 \le n$, $m \le 500$), the dimensions of the wall. In each of the next $n$ lines, there are $m$ characters $c_{ij}$, describing the wall. Each character will be either "." or "#" (without quotes).

Output

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

Example 1

Input
3 3
...
...
..#
Output
36

Example 2

Input
4 4
....
.#..
#...
#.#.
Output
76

Example 3

Input
5 5
.....
#..#.
..#.#
.....
..#..
Output
154

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) and (4, 1) simultaneously.

Source
COCI 2024/2025 Contest 5
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code