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>
int g[50][50];
typedef std::pair<int,int> P;
const int INF=100000000;
using namespace std;

int main(){

  int H,W;
  int ans;
  int k=0;
  cin>>H>>W;
  std::vector<string> s(H);
  for(int i=0;i<H;i++)cin>>s[i];
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)g[i][j]=INF;
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(s[i][j]=='.')k++;
  ans=k+1;

  queue<P> que;
  que.push(P(0,0));
  g[0][0]=1;
  int x[4]={0,0,1,-1};
  int y[4]={1,-1,0,0};
  while(que.size()){
    P l=que.front();
    que.pop();
    if(l.first==H-1&&l.second==W-1){
      ans=g[H-1][W-1];
      break;
    }
    else{
      for(int i=0;i<4;i++){
        int yy=l.first+y[i];
        int xx=l.second+x[i];
        if(xx>=0&&xx<W&&yy>=0&&yy<H&&s[yy][xx]=='.'&&g[yy][xx]==INF){
          g[yy][xx]=g[l.first][l.second]+1;
          que.push(P(yy,xx));
        }
      }
    }
  }
  cout<<k-ans<<endl;
}
