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<bits/stdc++.h>
using namespace std;
struct E{int x,y,c;};
signed main(){
  int w,h,ans=0;
  char ma[55][55];
  cin>>h>>w;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      cin>>ma[i][j];
      if(ma[i][j]=='.')ans++;
    }
  int used[55][55]={};
  queue<E> q;
  q.push((E){0,0,0});
  int f=0;
  while(!q.empty()){
    int x=q.front().x;
    int y=q.front().y;
    int c=q.front().c;
    q.pop();
    if(x==h-1&&y==w-1){
      f=1;
      ans-=c;
      break;
    }
    if(x<0||y<0||x==h||y==w)continue;
    if(used[x][y]||ma[x][y]=='#')continue;
    used[x][y]=1;
    q.push((E){x+1,y,c+1});
    q.push((E){x-1,y,c+1});
    q.push((E){x,y+1,c+1});
    q.push((E){x,y-1,c+1});
  }
  if(f)cout<<ans-1<<endl;
  else cout<<-1<<endl;
  return 0;
}