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

struct point{
	int x;
	int y;
	int d;
}q[2505];

int n,m,a[55][55],s,t,w,mo[4][2]={1,0,0,1,-1,0,0,-1};
bool v[55][55];

int main(){
	char ch;
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		for (j=1;j<=m;j++){
			cin>>ch;
			if (ch=='.'){
				a[i][j]=0;
				s++;
			}
			else{
				a[i][j]=1;
			}
		}
	}
	t=1;
	w=1;
	q[1].x=1;
	q[1].y=1;
	q[1].d=1;
	v[1][1]=true;
	while (t<=w){
		int xx,yy;
		for (i=0;i<4;i++){
			xx=q[t].x+mo[i][0];
			yy=q[t].y+mo[i][1];
			if (xx>=1 && xx<=n && yy>=1 && yy<=m){
				if (!v[xx][yy] && a[xx][yy]==0){
					w++;
					q[w].x=xx;
					q[w].y=yy;
					v[xx][yy]=true;
					q[w].d=q[t].d+1;
					if (xx==n && yy==m){
						printf("%d",s-q[w].d);
						return 0;
					}
				}
			}
		}
		t++;
	}
	printf("-1");
	return 0;
}