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;

const int inf = 1e4;

vector< vector<int> > dp(50,vector<int>(50,inf));

int dx[4] = {0,0,-1,1};
int dy[4] = {1,-1,0,0};

int main(){

	int h,w;
	cin>>h>>w;
	string s[h];
	for(int i = 0;i < h;i++){
		cin>>s[i];
	}

	dp[0][0] = 0;

	for(int l = 1;l<=h*w;l++){
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			for(int k = 0;k<4;k++){
				int x = i+dx[k],y=j+dy[k];
				if(x<0 || y<0 || x>=h || y>=w) continue;
				if(s[x][y]=='#' || s[i][j] == '#') continue;
				dp[x][y] = min(dp[x][y],dp[i][j]+1);
				//cout<<x<<" "<<y<<endl;
				//return 0;
			}
		}
	}
}

	// for(int i = 0;i<h;i++){
	// 	for(int j = 0;j<w;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }	

	int bl = 0;
	for(int i = 0;i < h;i++){
		for(int j = 0;j<w;j++){
			if(s[i][j]=='#') bl++;
		}
	}

	if(dp[h-1][w-1]>=inf) cout<<-1;
	else cout<<(h*w)-1-dp[h-1][w-1]-bl;

}