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"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const long long INF=1000000007;
using ll=long long;

int main() {
	int W,H,ans=0;
	char s[55][55];
	cin>>H>>W;
	rep(j,1,H+1)rep(i,1,W+1){
		cin>>s[i][j];
		if(s[i][j]=='.')ans++;
	}
	//BFS;
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	queue<P> que;
	int dist[55][55];
	rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
	dist[1][1]=1;
	que.push(P(1,1));
	while(que.size()){
		P p=que.front();
		que.pop();
		rep(i,0,4){
			int next_x=p.first+dx[i];
			int next_y=p.second+dy[i];
			if(s[next_x][next_y]=='.'&&
				next_x>0&&next_x<=W&&
				next_y>0&&next_y<=H&&
				dist[next_x][next_y]==INF){
				que.push(P(next_x,next_y));
				dist[next_x][next_y]=dist[p.first][p.second]+1;
			}
		}
	}
	if(dist[W][H]==INF)cout<<"-1"<<endl;
	else cout<<ans-dist[W][H]<<endl;
}