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<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

bool used[100][100];
int dist[100][100];
int dy[]={0,0,-1,1};
int dx[]={1,-1,0,0};
int main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  r(i,h)cin>>s[i];
  queue<P>q;
  q.push(P(0,0));
  used[0][0]=0;
  dist[0][0]=0;
  while(!q.empty()){
    P p=q.front();q.pop();
    int x=p.fi%100;
    int y=p.fi/100;
    dist[y][x]=p.se;
    r(i,4){
      int yy=y+dy[i];
      int xx=x+dx[i];
      if(xx<0||yy<0||y>=h||x>=w)continue;
      if(used[yy][xx])continue;
      if(s[yy][xx]=='#')continue;
      used[yy][xx]=1;
      q.push(P(yy*100+xx,p.se+1));
    }
  }
  int sum1=0;
  r(i,h)r(j,w)if(s[i][j]=='#')sum1++;
  if(dist[h-1][w-1]==0)cout<<-1<<endl;
  else cout<<h*w-(dist[h-1][w-1]+1+sum1)<<endl;
}