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 <iostream>
#include <queue>
#include <utility>
int main(){
  using pair = std::pair<int,int>;
  int bfs[51][51],h,w,i,j,dx[]={1,-1,0,0},dy[]={0,0,1,-1},inf=1001001001,a=0;
  std::cin>>h>>w;
  char m[h][w];
  std::queue<pair> q;
  pair p={0,0};
  q.push(p);
  for(i=0;i<h;++i)for(j=0;j<w;++j)bfs[i][j]=inf;
  bfs[0][0]=1;
  for(i=0;i!=h;++i){
    for(j=0;j!=w;++j){
      std::cin>>m[i][j];
      (m[i][j]=='.'?++a:0);
    }
  }
  while(q.size()){
    p = q.front();
    q.pop();
    if(p.first==h-1&&p.second==w-1)break;
    for(int i=0;i<4;++i){
        if(p.second+dx[i]>=0&&p.second+dx[i]<w&&p.first+dy[i]>=0&&p.first+dy[i]<h&&bfs[p.first+dy[i]][p.second+dx[i]]==inf&&m[p.first+dy[i]][p.second+dx[i]]=='.'){
          q.push({p.first+dy[i],p.second+dx[i]});
          bfs[p.first+dy[i]][p.second+dx[i]]=bfs[p.first][p.second]+1;
      }
    }
  }
  std::cout<<(bfs[h-1][w-1]==inf?-1:a-bfs[h-1][w-1])<<"\n";
}