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 <climits>

using namespace std;


int H, W;
char field[50][51];
int chkd[50][50];

void search(int px, int py, int score, int &min)
{
	if (px == W - 1 && py == H - 1)
	{
		if (min > score) min = score;
		return;
	}

	int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };
	for (int i = 0; i < 4; i++)
	{
		int x = px + dx[i], y = py + dy[i];
		if (x < 0 || x >= W || y < 0 || y >= H) continue;
		if (chkd[y][x] <= score + 1) continue;
		if (field[y][x] == '#') continue;
		chkd[y][x] = score + 1;
		search(x, y, score + 1, min);
	}
}

int main()
{
	cin >> H >> W;

	int black = 0;
	for (int i = 0; i < H; i++)
	{
		cin >> field[i];
		for (int j = 0; j < W; j++)
		{
			if (field[i][j] == '#') black++;
			chkd[i][j] = INT_MAX;
		}
	}

	int ans = INT_MAX;
	search(0, 0, 0, ans);
	if (ans != INT_MAX)
		cout << (W * H - black - ans - 1) << endl;
	else
		cout << -1 << endl;

	return 0;
}