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<cstdio>
#include<algorithm>
using namespace std;

struct node{
	int x,y;
}que[100001],t;

int dx[5]={-1,0,0,1,-1},dy[5]={-1,1,-1,0,0},vis[51][51],n,m,dis[51][51],a[51][51],s;
char x;

int bfs(){
	int l=1,r=1;
	que[1].x=1;
	que[1].y=1;
	dis[1][1]=1;
	vis[1][1]=true;
	while(l<=r){
		t=que[l];
		l++;
		for(int i=1;i<=4;i++){
			int x=t.x+dx[i],y=t.y+dy[i];
			if(x<1 || x>n || y<1 || y>m)continue;
			if(x==n && y==m)return dis[t.x][t.y]+1;
			if(!vis[x][y] && a[x][y]){
				que[++r].x=x;
				que[r].y=y;
				dis[x][y]=dis[t.x][t.y]+1;
				vis[x][y]=true;
			}
		}
	}
	return -1;
}

int main(){
	cin >> n >> m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			cin >> x;
			if(x=='.')
				a[i][j]=1;
			else
				s++;
		}
	int x=bfs();
	if(x==-1)
		cout << -1;
	else
		cout << n*m-s-x;
	return 0;
}