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>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int H,W;
char s[50][50];
int cnt[50][50];
int dx[4]={ 0, 1, 0,-1};
int dy[4]={ 1, 0,-1, 0};

void dfs(int x, int y){
  for(int i = 0; i < 4; i++){
    int nx = x + dx[i], ny = y + dy[i];
    if(nx<0 || nx>W-1 || ny<0 || ny>H-1) continue;
    if(s[ny][nx]=='.' && cnt[ny][nx]>cnt[y][x]+1){
      cnt[ny][nx] = cnt[y][x]+1;
      dfs(nx, ny);
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> H >> W;
  int wht = 0;
  REP(h,H) REP(w,W){
    cin >> s[h][w];
  	if(s[h][w]=='.') wht++;
    cnt[h][w] = H*W;
  }
  cnt[0][0] = 1;
  dfs(0,0);
  
  cout << (cnt[H-1][W-1]<H*W ? wht-cnt[H-1][W-1] : -1) << endl;
  return 0;
}