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 <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
int h,w,ch[50][50],nx,ny,dx[]={0,0,1,-1},dy[]={1,-1,0,0},tot;
string dp[50];
queue<pair<int,int>> que;
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        cin>>dp[i];
        for(int j=0;j<w;j++){
            if(dp[i][j]=='.')tot++;
        }
    }
    que.push({0,0});
    ch[0][0]=1;
    while(!que.empty()){
        auto q=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            nx=q.F+dx[i];
            ny=q.S+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&dp[nx][ny]=='.'){
                if(ch[nx][ny]==0){
                    ch[nx][ny]=1+ch[q.F][q.S];
                    que.push({nx,ny});
                }
            }
        }
    }
    
    if(ch[h-1][w-1]==0)cout<<-1<<endl;
    else {
        cout<<(tot-ch[h-1][w-1])<<endl;
    }
}
