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<queue>
using namespace std;
string s[50];
int h,w;
int d[5]={0,1,0,-1};
int dis[50][50];
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)cin>>s[i];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)dis[i][j]=1e9;
	dis[0][0]=1;
	queue<pair<int,int> >P;
	P.push(make_pair(0,0));
	while(!P.empty())
	{
		int x=P.front().first,y=P.front().second;P.pop();
		for(int r=0;r<4;r++)
		{
			int tx=x+d[r],ty=y+d[r+1];
			if(tx<0||ty<0||tx>=h||ty>=w||dis[tx][ty]<=dis[x][y]+1||s[tx][ty]=='#')continue;
			dis[tx][ty]=dis[x][y]+1;
			P.push(make_pair(tx,ty));
		}
	}
	if(dis[h-1][w-1]<1e9)
	{
		int cnt=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)cnt+=s[i][j]=='.';
		cnt-=dis[h-1][w-1];
		cout<<cnt<<endl;
	}
	else cout<<-1<<endl;
}