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;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (auto &e : s) {
		cin >> e;
	}
	vector<pair<int, int>> d = {make_pair(1, 0), make_pair(0, 1), make_pair(-1, 0), make_pair(0, -1)};
	vector<vector<int>> a(h, vector<int>(w, INT_MAX));
	queue<pair<int, int>> q;
	a[0][0] = 0;
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		auto f = q.front();
		q.pop();
		for (auto e : d) {
			int i = f.first + e.first, j = f.second + e.second;
			if (0 <= i && i < h && 0 <= j && j < w && s[i][j] == '.') {
				if (a[f.first][f.second] + 1 < a[i][j]) {
					a[i][j] = a[f.first][f.second] + 1;
					q.push(make_pair(i, j));
				}
			}
		}
	}
	int m;
	if (a[h - 1][w - 1] == INT_MAX) {
		m = -1;
	} else {
		int t = 0;
		for (auto r : s) {
			for (auto e : r) {
				t += e == '.';
			}
		}
		m = t - a[h - 1][w - 1] - 1;
	}
	cout << m << endl;
	return 0;
}
