P8217 [THUPC 2022 Preliminary] Counting Cubes

Description

Xiao E has a rectangular area of size $n\times m$. It contains $n\times m$ unit grid cells. On the cell in row $i$ and column $j$, there are $A_{i,j}$ identical cube blocks stacked. After solving a certain problem, Xiao E suddenly wanted to draw these cubes as ASCII art, and asks you to help him count how many cubes he has in total. We define each cube in the following format. There will be no rotation; cubes are placed strictly in this one form: ``` ..+---+ ./ /| height +---+ | | | + | |/. width +---+.. length ``` Each vertex is represented by one `+`. The length is represented by three `-`. The width is represented by one `/`. The height is represented by two `|`. The character `.` is used as the background. The blank area in the middle is a space (ASCII code $32$). If two cubes are adjacent left to right, they look like: ``` ..+---+---+ ./ / /| +---+---+ | | | | + | | |/. +---+---+.. ``` If two cubes are adjacent up and down, they look like: ``` ..+---+ ./ /| +---+ | | | + | |/| +---+ | | | + | |/. +---+.. ``` If two cubes are adjacent front to back, they look like: ``` ....+---+ .../ /| ..+---+ | ./ /| + +---+ |/. | | +.. | |/... +---+.... ``` The faces of the cube in front will block the faces of the cube behind. To make sure you can see clearly and that no entire column of cubes is completely blocked behind, Xiao E guarantees that $1\le A_{ij} \le A_{i-1,j}$ and $1\le A_{ij}\le A_{i,j-1}$. Also, there is no entire row or entire column of `.` in the picture. Therefore, one ASCII art corresponds to a unique matrix $A$, and one matrix $A$ also corresponds to a unique ASCII art.

Input Format

The first line contains two positive integers $r,c$, meaning the height and width of the picture (note that these are not $n$ and $m$). Next comes an ASCII art of $r$ rows and $c$ columns, describing the cubes stacked by Xiao E.

Output Format

Output one integer in one line, representing the number of cubes.

Explanation/Hint

[Sample Explanation] At this time, the matrix $A$ is $$\begin{bmatrix}3 & 3 & 2 \\ 3 & 2 & 1\end{bmatrix}$$ Since $3+3+3+2+2+1=14$, there are $14$ cubes in the picture. [Constraints] It is guaranteed that $1\le n,m \le 50$ and $1\le A_{ij}\le 100$ (note that here these are $n$ and $m$, not $r$ and $c$). It is guaranteed that $\forall 1