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>
using lint=long long;
using namespace std;

const int dw[]={1,0,-1,0};
const int dh[]={0,-1,0,1};

class info
{
	public:
	int h,w,dist;
};

int main()
{
	int H,W;
	char s[55][55];
	int wcnt=0;
	
	cin >> H >> W;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{
			cin >> s[i][j];
			if(s[i][j]=='.')
				wcnt++;
		}
	}
	
	queue<info> q;
	q.push({0,0,1});
	int dist=-1;
	while(!q.empty())
	{
		info cur=q.front();
		q.pop();
		
		if(cur.h==H-1 && cur.w==W-1)
		{
			dist=cur.dist;
			break;
		}
		
		for(int i=0;i<4;i++)
		{
			int nh=cur.h+dh[i];
			int nw=cur.w+dw[i];
			if(nh<0 || nw<0 || nh>=H || nw>=W)continue;
			if(s[nh][nw]=='.')
			{
				q.push({nh,nw,cur.dist+1});
				s[nh][nw]='#';
			}
		}
	}
	
	if(dist==-1)
		cout << -1;
	else
		cout << wcnt-dist;
	cout << endl;
	return 0;
}