Problem: 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

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
queue<int> ver;
queue<int> hor;
bool vis[100000][10000];
int dx[]={1,-1,0,0};
int dy[]={0,0,-1,1};
int main(){
	string s[55];
	int row,col;
	scanf("%d%d",&row,&col);
	int ban=0;
	for(int i=0;i<row;i++){
		cin>>s[i];
		int leng=s[i].size();
		for(int j=0;j<leng;j++){
			if(s[i][j]=='.')ban++;
		}
	}
	ver.push(0);
	hor.push(0);
	int step=0;
	bool flag=false;
	while(!ver.empty()){
		int sz=ver.size();
		for(int i=0;i<sz;i++){
			int I=ver.front(),J=hor.front();
			if(I==row-1 && J==col-1){
				flag=true;
				break;
			}
			for(int j=0;j<4;j++){
				int x=I+dx[j];
				int y=J+dy[j];
				if(x>=0 && y>=0 && x<row && y<col){
					if(!vis[x][y]){
						vis[x][y]=1;
						if(s[x][y]=='.'){
							ver.push(x);
							hor.push(y);	
						}
					}
				}
			}
			ver.pop();
			hor.pop();
		}
		if(flag==true)break;
		step++;
	}
	if(flag==true)printf("%d\n",ban-step-1);
	else printf("-1\n");
}