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 dh[4] = {0, 1, 0, -1};
int dw[4] = {1, 0, -1, 0};
vector<string> field;

int main() {
  int H,W,i,j,w=0;
  pair<int,int> p;
  cin >> H >> W;
  field.resize(H);
  for(i=0; i<H; i++)
    cin >> field.at(i);
  
  for(i=0; i<H; i++)
    for(j=0; j<W; j++)
      if(field.at(i).at(j) == '.')
        w++;

  vector<vector<int>> d(H, vector<int>(W,-1));
  queue<pair<int,int>> q;

  d.at(0).at(0) = 0;
  q.push(make_pair(0,0));

  while(!q.empty()) {
    p = q.front();
    q.pop();

    for(i=0; i<4; i++) {
      int nh=p.first+dh[i], nw=p.second+dw[i];
      if(nh>=0 && nw>=0 && nh<H && nw<W &&
         field.at(nh).at(nw)=='.' && d.at(nh).at(nw)==-1) {
        d.at(nh).at(nw) = d.at(p.first).at(p.second)+1;
        q.push(make_pair(nh, nw));
      }
    }
  }
  
  if(d.at(H-1).at(W-1) == -1)
    cout << -1;
  else
    cout << w-1-d.at(H-1).at(W-1);
  cout << endl;
}