Problem: Constraints

* H is an integer between 2 and 50 (inclusive).
* W is an integer between 2 and 50 (inclusive).
* s_{i, j} is `.` or `#` (1 \leq i \leq H, 1 \leq j \leq W).
* s_{1, 1} and s_{H, W} are `.`.

Input

Input is given from Standard Input in the following format:


H W
s_{1, 1}s_{1, 2}s_{1, 3} ... s_{1, W}
s_{2, 1}s_{2, 2}s_{2, 3} ... s_{2, W}
:   :
s_{H, 1}s_{H, 2}s_{H, 3} ... s_{H, W}


Output

Print the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed.

Examples

Input

3 3
..#
#..
...


Output

2


Input

3 3
..#
..
...


Output

2


Input

10 37
.....................................
...#...####...####..###...###...###..
..#.#..#...#.##....#...#.#...#.#...#.
..#.#..#...#.#.....#...#.#...#.#...#.
.#...#.#..##.#.....#...#.#.###.#.###.
.#####.####..#.....#...#..##....##...
.#...#.#...#.#.....#...#.#...#.#...#.
.#...#.#...#.##....#...#.#...#.#...#.
.#...#.####...####..###...###...###..
.....................................


Output

209

Solution (in PYTHON):

Solution:
H, W = map(int, raw_input().split())
dungeon = []
memo = []
whitecount = 0
for i in range(0, H):
	dlst = []
	nlst = []
	s = raw_input()
	for j in range(0, W):
		if s[j] == '.': whitecount += 1
		dlst.append(s[j]=='.')
		nlst.append(H*W+1)
	dungeon.append(dlst)
	memo.append(nlst)
max = -1
queue = [[0, 0, 1]]
while queue != []:
	now = queue.pop(0)
	if now[2] < memo[now[0]][now[1]] and dungeon[now[0]][now[1]]:
		memo[now[0]][now[1]] = now[2]
		for i in range(0, 2):
			nexth = now[0] - 1 + 2*i
			nextw = now[1] - 1 + 2*i
			if 0 <= nexth and nexth < H:
				queue.append([nexth, now[1], now[2]+1])
			if 0 <= nextw and nextw < W:
				queue.append([now[0], nextw, now[2]+1])
if max < whitecount - memo[H-1][W-1]:
	max = whitecount-memo[H-1][W-1]
print max