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

public class Main {
    static boolean[][] a;
    static boolean[][] b;
    static int[][] nexts = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        a = new boolean[h][w];
        b = new boolean[h][w];
        int block = h * w;
        for (int i = 0; i < h; i++) {
            char[] line = scan.next().toCharArray();
            for (int j = 0; j < w; j++) {
                a[i][j] = line[j] == '.';
                block -= line[j] == '.' ? 1: 0;
            }
        }
        Deque<Tuple> q = new ArrayDeque<>();
        q.add(new Tuple(1, 0, 0));
        while (!q.isEmpty()) {
            Tuple c = q.removeFirst();
            if(c.x == w -1 && c.y == h - 1) {
                System.out.println(h *w - block - c.s);
                return;
            }
            for(int[] diff: nexts) {
                int nx = c.x + diff[0];
                int ny =  c.y + diff[1];
                if(nx< 0 || w <= nx || ny< 0 || h <=ny || !a[ny][nx] || b[ny][nx]) {
                    continue;
                }
                b[ny][nx] = true;
                q.addLast(new Tuple(c.s+1, nx, ny));
            }
        }
        System.out.println(-1);
    }

    static class Tuple{
        int s;
        int x;
        int y;
        Tuple(int s, int x, int y) {
            this.s = s;
            this.x = x;
            this.y = y;
        }
    }
}

