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>
using namespace std;
using ll=long long;

int main(){
  bool s[50][50]={0};
  int H,W;
  cin>>H>>W;
  char tmp;
  int white=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>tmp;
      if(tmp=='.'){
        s[i][j]=1;
        white++;
      }
    }
  }
  int dis[50][50]={0};
  dis[0][0]=1;

  int dx[]={0,0,1,-1};
  int dy[]={1,-1,0,0};

  queue<pair<int,int>> q;
  q.push({0,0});
  while(dis[H-1][W-1]==0&&!q.empty()){
    pair<int,int> pos=q.front();
    q.pop();
    int x=pos.first,y=pos.second;
    for(int i=0;i<4;i++){
      int newx=x+dx[i],newy=y+dy[i];
      if(newx>=0&&newx<=H-1&&newy>=0&&newy<=W-1&&dis[newx][newy]==0&s[newx][newy]){
        dis[newx][newy]=dis[x][y]+1;
        q.push({newx,newy});
      }
    }
  }
  if(dis[H-1][W-1]==0) cout<<-1<<endl;
  else cout<<white-dis[H-1][W-1]<<endl;

  return 0;
}

