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 main()
{
	int h, w;
	cin >> h >> w;
	string s[55];
	int b = h * w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		for (auto c : s[i])
			if (c != '.') b--;
	}
	int sh[] = { 0,1,0,-1,0 };
	int d[51][51] = {};
	queue<pair<int, int>> q;
	q.push(make_pair(0, 0));
	d[0][0] = 1;
	while (!q.empty()) {
		auto i = q.front();
		if (i.first == h - 1 && i.second == w - 1)
			break;
		q.pop();
		for (int j = 0; j < 4; j++) {
			int x = i.first + sh[j];
			int y = i.second + sh[j + 1];
			if (x >= 0 && x < h&&y >= 0 && y < w&&s[x][y] == '.' && !d[x][y])
				q.push(make_pair(x, y)), d[x][y] = d[i.first][i.second] + 1;
		}
	}
	cout << (d[h - 1][w - 1] ? b - d[h - 1][w - 1] : -1) << endl;
	return 0;
}