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:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
h, w = map(int, raw_input().split())
# 文字列の入力
s = [raw_input() for i in range(h)]

accessible = [(0,0)]
accessible_now = [(0,0)]
n_black = sum([ss.count('#') for ss in s]) 

stroke = 1
while True:
  stroke += 1
  accessible_next = [] 
  for loc in accessible_now:
    for step in [(1,0),(0,1),(-1,0),(0,-1)]:
      loc_next = (loc[0]+step[0],loc[1]+step[1])
      if loc_next == (h-1,w-1):
        print h*w-n_black-stroke 
        exit(0)
      if ((-1 in loc_next) or (loc_next[0]==h) or (loc_next[1]==w)):
        continue
      if loc_next in accessible:
        continue
      if s[loc_next[0]][loc_next[1]] == '#':
        continue
      accessible.append(loc_next)
      accessible_next.append(loc_next)
  accessible_now = accessible_next
  if(len(accessible_next)==0):
    print -1
    exit(0)