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;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)

#define INF 1e9

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

vector<string> s;
int d[60][60];

void dfs(int y,int x,int cost){
    if (s[y][x] == '#') return;
    if (d[y][x] > cost) {
        d[y][x] = cost;
        rep(i,4) dfs(y+dy[i],x+dx[i],cost+1);
    }
}

int main(void){
    int h,w;
    cin>>h>>w;
    s = vector<string>(h+2);
    s[0] = s[h+1] = string(w+2,'#');
    rep(y,h){
        string line;
        cin>>line;
        s[y+1] = "#"+line+"#";
    }
    int dot = 0;
    rep1(y,h)rep1(x,w){
        d[y][x] = INF;
        if(s[y][x] == '.') dot++;
    }
    dfs(1,1,1);
    cout<<(d[h][w] == INF ? -1 :dot-d[h][w])<<endl;
    return 0;
}
