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:
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

struct node{
	int x,y,t;
}q[2501];
bool a[51][51],vis[51][51];
int d[4][2]={0,1,0,-1,1,0,-1,0};
int main()
{
	ios::sync_with_stdio(false);
	int n,m,tot=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			char c;
			cin>>c;
			if(c=='.') a[i][j]=1,tot++;
		}
	if(!a[1][1]||!a[n][m]){
		cout<<-1;return 0;
	}
	int t=1,w=1;
	q[1].x=1,q[1].y=1,q[1].t=1;vis[1][1]=1;
	while(t<=w){
		for(int i=0;i<4;i++){
			int x=q[t].x+d[i][0],y=q[t].y+d[i][1];
			if(x>0&&x<=n&&y>0&&y<=m&&a[x][y]&&!vis[x][y]){
				++w,q[w].x=x,q[w].y=y,q[w].t=q[t].t+1;
				if(x==n&&y==m){
					cout<<tot-q[w].t;
					return 0;
				}
				vis[x][y]=1;
			}
		}
		++t;
	}
	cout<<-1;
}