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 JAVA):

Solution:
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	static int[] dx = { 1, 0, -1, 0 };
	static int[] dy = { 0, 1, 0, -1 };
	static int h, w;
	static int[][] d;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		h = sc.nextInt();
		w = sc.nextInt();
		int x = 0, y = 0;
		char[][] map = new char[h][w];
		d = new int[h][w];
		for (int i = 0; i < h; i++) {
			map[i] = sc.next().toCharArray();
			Arrays.fill(d[i], Integer.MAX_VALUE);
		}
		map[0][0] = 'f';

		d[0][0] = 1;
		solve(map, x, y);
		int score;
		if (d[h - 1][w - 1] != Integer.MAX_VALUE) {
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (map[i][j] == '#') {
						cnt++;
					}
				}
			}
			score = h * w - cnt - d[h - 1][w - 1];
		} else {
			score = -1;
		}
		System.out.println(score);
	}

	private static void solve(char[][] map, int x, int y) {
		Deque<P> deque = new ArrayDeque<>();
		deque.add(new P(x, y));
		while (!deque.isEmpty()) {
			P p = deque.poll();
			if (p.x == w && p.y == h) {
				break;
			}
			for (int i = 0; i < 4; i++) {
				int xx = p.x + dx[i];
				int yy = p.y + dy[i];
				if (xx >= 0 && xx < w && yy >= 0 && yy < h && map[yy][xx] == '.' && d[yy][xx] == Integer.MAX_VALUE) {
					deque.add(new P(xx, yy));
					d[yy][xx] = d[p.y][p.x] + 1;
				}
			}
		}
	}
}

class P {
	int x;
	int y;

	public P(int x, int y) {
		this.x = x;
		this.y = y;
	}
}