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.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		char[][] maze = new char[h][w];
		for (int x = 0; x < h; x++) {
			maze[x] = in.next().toCharArray();
		}
		int countdot = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (maze[i][j] == '.') countdot++;
			}
		}
		int[][] v = new int[h][w];
		for (int y = 0; y < h; y++) {
			Arrays.fill(v[y], -1);
		}
		int sx = 0, sy = 0, gx = h-1, gy = w-1;
		int[] dx = {0,0,1,-1};
		int[] dy = {1,-1,0,0};
		Deque<P> q = new ArrayDeque<>();
		q.push(new P(sx, sy));
		v[sx][sy] = 1;

		while (!q.isEmpty()) {
			P p = q.pop();
			int x = p.x;
			int y = p.y;

			for (int i = 0; i < 4; i++) {
				int mx = x + dx[i];
				int my = y + dy[i];
				if (mx < 0 || mx >= h || my < 0 || my >= w || maze[mx][my] == '#') {
					continue;
				}
				if (v[mx][my] != -1) {
					continue;
				}
				q.add(new P(mx, my));
				v[mx][my] = v[x][y] + 1;
			}
		}
		int ans = v[gx][gy] != -1 ? countdot - v[gx][gy] : -1;
		System.out.println(ans);
	}

	public static class P {
		int x;	// 縦
		int y;	// 横

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

}
