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.*;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int hight = sc.nextInt();
		int width = sc.nextInt();
		int ans = 0;
		
		char[][] meiz = new char[hight][width];
		int[][] map = new int[hight][width];
		
		
			for(int j=0;j<hight;j++){
				String line = sc.next();
				for(int i=0;i<width;i++){
				
				meiz[j][i] = line.charAt(i);
				ans += (meiz[j][i]== '.' ? 1 : 0);
				map[j][i] = (meiz[j][i]== '.' ? 0 : -1);
				}
			}
		
			map[0][0] = 1;
			int cost=0;
			boolean check;
			
			for(cost=1;map[hight-1][width-1]==0;cost++){
				check = true;
				for(int j=0;j<hight;j++)
					for(int i=0;i<width;i++){
						
						
				
						if(map[j][i]==cost){
							work(meiz,map,j,i,cost);
							check = false;
						}
				
					}
				if(check) break;
			}
			
			if(map[hight-1][width-1]==0)
				System.out.println("-1");
			else
				System.out.println(ans-cost);
//			for(int j=0;j<hight;j++){
//				for(int i=0;i<width;i++){
//				
//				System.out.print(map[j][i]);
//				}
//				System.out.println();
//			}
	}

	private static void work(char[][] meiz,int[][] map, int j, int i ,int cost) {
		// TODO 自動生成されたメソッド・スタブ
		
		if(j>0) check(meiz,map,j-1,i,cost);
		if(i>0) check(meiz,map,j,i-1,cost);
		if(j<meiz.length-1) check(meiz,map,j+1,i,cost);
		if(i<meiz[0].length-1) check(meiz,map,j,i+1,cost);
		
	}

	private static void check(char[][] meiz,int[][] map, int j, int i, int cost) {
		
		if(meiz[j][i]== '.')
			if(map[j][i]==0)
				map[j][i] = cost+1;
	}

	
}