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
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

class Main{
    static int[][] path=new int[50][50];



    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int H=scan.nextInt();
        int W=scan.nextInt();
        int cnt =0;
        for(int[] i : path)Arrays.fill(i,-1);
        for(int i=0;i<H;++i){
            String s = scan.next();
            for(int j=0;j<W;++j){
                path[i][j]=(s.charAt(j)=='.' ? 10000:-1);
                if(s.charAt(j)=='.')++cnt;
            }
        }
        int[] dx ={0,-1,0,1};
        int[] dy={1,0,-1,0};

        path[0][0]=1;
        Deque<Integer> que = new ArrayDeque<>();
        que.add(0);
        while(!que.isEmpty()){
            int h = que.peek()/W;
            int w = que.poll()%W;
            for(int i=0;i<4;++i){
                if(h+dy[i]<0 || h+dy[i] >=H || w+dx[i]<0 || w+dx[i]>=W || path[h+dy[i]][w+dx[i]]==-1 || path[h+dy[i]][w+dx[i]]<=path[h][w]+1)continue;
                path[h+dy[i]][w+dx[i]]=path[h][w]+1;
                que.add((h+dy[i])*W + w+dx[i]);
            }
        }
        if(path[H-1][W-1]==-1 || path[H-1][W-1]==10000)System.out.println(-1);
        else System.out.println(cnt - path[H-1][W-1]);
    }
}