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>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

char s[50][50];
int dx[]{1,-1,0,0},dy[]{0,0,1,-1};
int d[50][50];

signed main(){
	int h,w;scanf("%d%d",&h,&w);
	rep(i,h)scanf("%s",s[i]);
	queue<P>que;que.push(P(0,0));
	memset(d,-1,sizeof(d));d[0][0]=0;
	while(!que.empty()){
		P p=que.front();que.pop();
		rep(i,4){
			int nx=p.first+dx[i],ny=p.second+dy[i];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&d[nx][ny]==-1&&s[nx][ny]!='#'){
				d[nx][ny]=d[p.first][p.second]+1;
				que.push(P(nx,ny));
			}
		}
	}
	int cnt=0;
	rep(i,h)rep(j,w){
		if(s[i][j]=='#')cnt++;
	}
	if(d[h-1][w-1]==-1){puts("-1");return 0;}
	int a=h*w-d[h-1][w-1];
	cout<<a-cnt-1<<endl;
}