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 <iostream>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define pi pair<int,int>

const long INF = 10101010;

using namespace std;

int h, w, add, ans, B[101][101], di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 },{ 0,-1 } };
char A[101][101];
queue <pi> q; pi st, go;

int main() {
	cin >> h >> w;
	rep(i, h) rep(j, w) {
		cin >> A[i][j];
		if (A[i][j] == '#') add++;
		B[i][j] = INF;
	}
	B[0][0] = 0;
	add = h * w - add - 1;

	st.first = 0; st.second = 0;

	q.push(st);
	while (!q.empty()) {
		pi x = q.front();
		q.pop();
		rep(i, 4) {
			int X = x.first + di[i][0], Y = x.second + di[i][1];
			if (X >= 0 && Y >= 0 && X < h && Y < w) {
				if (A[X][Y] != '#' && B[X][Y] == INF) {
					q.push(pair<int, int>(X, Y));
					B[X][Y] = B[x.first][x.second] + 1;
				}
			}
		}
	}

	if (B[h - 1][w - 1] == INF) cout << -1 << endl;
	else cout << add - B[h - 1][w - 1] << endl;

	return 0;
}