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>
using namespace std;

int h, w;
string s[50];
int d[50][50];
bool b[50][50];

int v[][2] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };

void dfs(int x, int y) {
	for (int i = 0, nx, ny; i < 4; i++) {
		nx = x + v[i][0], ny = y + v[i][1];
		if (nx < 0 || nx >= h || ny < 0 || ny >= w || s[nx][ny] == '#')
			continue;
		if (d[nx][ny] > d[x][y] + 1) {
			d[nx][ny] = d[x][y] + 1;
			dfs(nx, ny);
		}
	}
}

int main() {
	fill(d[0], d[50], 250);
	cin >> h >> w;
	int black = 0;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#')
				black++;
		}
	}

	d[0][0] = 0;
	dfs(0, 0);
	int ans =
			d[h - 1][w - 1] != 250 ? h * w - black - (d[h - 1][w - 1] + 1) : -1;
	cout << ans << endl;

}