atcoder#ABC232D. [ABC232D] Weak Takahashi

[ABC232D] Weak Takahashi

Score : 400400 points

Problem Statement

There is a H×WH \times W-square grid with HH horizontal rows and WW vertical columns. Let (i,j)(i, j) denote the square at the ii-th row from the top and jj-th column from the left. Each square is described by a character Ci,jC_{i, j}, where Ci,j=C_{i, j} = . means (i,j)(i, j) is an empty square, and Ci,j=C_{i, j} = # means (i,j)(i, j) is a wall.

Takahashi is about to start walking in this grid. When he is on (i,j)(i, j), he can go to (i,j+1)(i, j + 1) or (i+1,j)(i + 1, j). However, he cannot exit the grid or enter a wall square. He will stop when there is no more square to go to.

When starting on (1,1)(1, 1), at most how many squares can Takahashi visit before he stops?

Constraints

  • 1H,W1001 \leq H, W \leq 100
  • HH and WW are integers.
  • Ci,j=C_{i, j} = . or Ci,j=C_{i, j} = #. (1iH,1jW)(1 \leq i \leq H, 1 \leq j \leq W)
  • C1,1=C_{1, 1} = .

Input

Input is given from Standard Input in the following format:

HH WW

C1,1C1,WC_{1, 1} \ldots C_{1, W}

\vdots

CH,1CH,WC_{H, 1} \ldots C_{H, W}

Output

Print the answer.

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

For example, by going $(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (3, 2)$, he can visit 44 squares.

He cannot visit 55 or more squares, so we should print 44.

1 1
.
1
5 5
.....
.....
.....
.....
.....
9