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.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGridRepainting solver = new DGridRepainting();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGridRepainting {
        private static final int[] MVX = {0, 1, 0, -1, 0, 1, 1, -1, -1};
        private static final int[] MVY = {0, 0, 1, 0, -1, 1, -1, -1, 1};
        private static String[] board;
        private static int[][] distance;

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int h = in.ints(), w = in.ints();
            board = new String[h + 2];
            distance = new int[h + 2][w + 2];
            ArrayUtil.fill(distance, Integer.MAX_VALUE);
            distance[1][1] = 1;

            board[0] = "####################################################";
            board[h + 1] = "####################################################";
            int black = 0;
            for (int i = 1; i <= h; i++) {
                String s = in.string();
                black += s.chars().filter(c -> c == '#').count();
                board[i] = "#" + s + "#";
            }
            dfs(1, 1);
            if (distance[h][w] == Integer.MAX_VALUE) {
                out.println(-1);
            } else {
                out.println(h * w - black - distance[h][w]);
            }
        }

        public void dfs(int x, int y) {
            for (int i = 1; i <= 4; i++) {
                int nx = x + MVX[i];
                int ny = y + MVY[i];
                if (board[ny].charAt(nx) == '.' && distance[y][x] + 1 < distance[ny][nx]) {
                    distance[ny][nx] = distance[y][x] + 1;
                    dfs(nx, ny);
                }
            }
        }

    }

    static final class ArrayUtil {
        private ArrayUtil() {
        }

        public static void fill(int[] a, int v) {
            Arrays.fill(a, v);
        }

        public static void fill(int[][] a, int v) {
            for (int i = 0; i < a.length; i++) {
                fill(a[i], v);
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}