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
#include <bits/stdc++.h>
using namespace std;

int h,w,grid[52][52],cnt=0;

void solve(int x, int y){
	if(grid[x-1][y]>grid[x][y]+1){
		grid[x-1][y]=grid[x][y]+1;
		solve(x-1,y);
	}
	if(grid[x][y-1]>grid[x][y]+1){
		grid[x][y-1]=grid[x][y]+1;
		solve(x,y-1);
	}
	if(grid[x+1][y]>grid[x][y]+1){
		grid[x+1][y]=grid[x][y]+1;
		solve(x+1,y);
	}
	if(grid[x][y+1]>grid[x][y]+1){
		grid[x][y+1]=grid[x][y]+1;
		solve(x,y+1);
	}
}


int main(){
	cin>>h>>w;
	grid[0][0]=0;
	grid[h+1][w+1]=0;
	for(int i=1;i<=h;i++){
		grid[i][0]=0;
		grid[i][w+1]=0;
		for(int j=1;j<=w;j++){
			if(i==1){
				grid[0][j]=0;
				grid[h+1][j]=0;
			}
			char tmp;
			cin>>tmp;
			if(tmp=='.'){
				grid[i][j]=3000;
				cnt++;
			}else{
				grid[i][j]=0;
			}
		}
	}
	grid[1][1]=1;
	solve(1,1);
	if(grid[h][w]==3000){
		cout<<-1<<endl;
	}else{
		cout<<cnt-grid[h][w]<<endl;
	}
	
}