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;
int main(){
  long h,w;cin>>h>>w;
  long b=0;
  vector<string>S(h);for(long i=0;i<h;i++){
    cin>>S[i];
    for(char c:S[i])if(c=='#')b++;
  }
  vector<long>D(w*h,-1);D[0]=0;
  queue<long>q;q.push(0);
  while(q.size()){
    long f=q.front();q.pop();
    if(f/w-1>=0&&D[f-w]==-1&&S[f/w-1][f%w]!='#'){
      D[f-w]=D[f]+1;q.push(f-w);
    }
    if(f/w+1<h&&D[f+w]==-1&&S[f/w+1][f%w]!='#'){
      D[f+w]=D[f]+1;q.push(f+w);
    }
    if(f%w-1>=0&&D[f-1]==-1&&S[f/w][f%w-1]!='#'){
      D[f-1]=D[f]+1;q.push(f-1);
    }
    if(f%w+1<w&&D[f+1]==-1&&S[f/w][f%w+1]!='#'){
      D[f+1]=D[f]+1;q.push(f+1);
    }
  }
  cout<<(D[w*h-1]!=-1?(w*h)-D[w*h-1]-b-1:-1)<<endl;
}