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
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

int h,w;
int A[60][60];

void bfs(int u,int v){
  queue<pair<int,int>> q;
  q.push({u,v});
  while(!q.empty()){
    auto t=q.front(); q.pop();
    int nx,ny;
    for(int i=0;i<4;i++){
      ny=t.first+dy[i], nx=t.second+dx[i];
      if(ny<0 || ny>=h || nx<0 || nx>=w) continue;
      if(A[ny][nx]!=0) continue;
      A[ny][nx]=A[t.first][t.second]+1;
      q.push({ny,nx});
    }
  }
}

int main() {
  cin>>h>>w;
  
  char c;
  int cnt=0;
  rep(i,h){
    rep(j,w){
      cin>>c;
      if(c=='#'){
        A[i][j]=-1;
        cnt++;
      }
      else A[i][j]=0;
    }
  }
  A[0][0]=1;
  
  bfs(0,0);
  if(A[h-1][w-1]==0) cout<<-1<<endl;
  else cout<<h*w-cnt-A[h-1][w-1]<<endl;
  
  return 0;
}