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<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstring>
using namespace std;
const int N=100;
int dis[100][100];
bool dot[100][100];
vector<int> v1;
queue<int> q1;
int main(){
	int n,m;
	int i,j,k,t;
	int a,b,c,d;
	int s=0;
	char ca[100];
	memset(dis,-1,sizeof(dis));
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>ca;
		for(j=0;j<m;j++){
			if(ca[j]=='.')dot[i][j]=true,s++;
		}
	}
	q1.push(0);
	for(t=0;!q1.empty();t++){
		d=q1.size();
		for(i=0;i<d;i++){
			a=q1.front(),q1.pop();
			b=a%N,a/=N;
			if(!dot[a][b] || dis[a][b]!=-1)continue;
			dis[a][b]=t;
			for(j=-1;j<=1;j++){
				for(k=-1;k<=1;k++){
					if((j+k+4)%2==0)continue;
					if(a+j<0 || n<=a+j || b+k<0 || m<=b+k)continue;
					if(dis[a+j][b+k]!=-1 || !dot[a+j][b+k])continue;
					q1.push((a+j)*N+b+k);
				}
			}
		}
	}
	if(dis[n-1][m-1]!=-1){
		s-=dis[n-1][m-1]+1;
	}else s=-1;
	cout<<s<<endl;
	return 0;
}
