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
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String line = sc.nextLine();
		int H = Integer.parseInt(line.split(" ")[0]);
		int W = Integer.parseInt(line.split(" ")[1]);
		int[][] squares = new int[H][W];
		boolean[][] done = new boolean[H][W];
		int blocks = 0;
		for (int i = 0; i < H; i++) {
			line = sc.nextLine();
			for (int j = 0; j < W; j++) {
				if (line.substring(j, j + 1).equals("#")) {
					squares[i][j] = -1;
					blocks++;
				}
			}
		}
		Queue<P> q = new LinkedList<>();
		q.add(new P(0, 0, 0));
		while (!q.isEmpty()) {
			P p = q.poll();

			if (p.x < 0 || p.x >= H || p.y < 0 || p.y >= W)
				continue;
			if (squares[p.x][p.y] < 0)
				continue;
			if (done[p.x][p.y])
				continue;

			q.add(new P(p.x + 1, p.y, p.dist + 1));
			q.add(new P(p.x - 1, p.y, p.dist + 1));
			q.add(new P(p.x, p.y + 1, p.dist + 1));
			q.add(new P(p.x, p.y - 1, p.dist + 1));

			squares[p.x][p.y] = p.dist;
			done[p.x][p.y] = true;

			if (p.x == W - 1 && p.y == H - 1)
				break;
		}

		if (squares[H - 1][W - 1] <= 0) {
			System.out.println("-1");
		} else {
			System.out.println(H * W - squares[H - 1][W - 1] - 1 - blocks);
		}
	}
}

class P {
	int x;
	int y;
	int dist;

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