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.*;

class Node implements Comparable<Node> {
  int i, j, step;
  Node(int i, int j, int step) {
    this.i = i;
    this.j = j;
    this.step = step;
  }

  public int compareTo(Node node) {
    return this.step - node.step;
  }
}

public class Main {
  private static int[] DI = new int[]{1, 0, -1, 0};
  private static int[] DJ = new int[]{0, 1, 0, -1};

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int h = in.nextInt();
    int w = in.nextInt();

    boolean[][] m = new boolean[h+2][w+2];
    int numWhite = 0;
    for (int i = 1; i <= h; i++) {
      String line = in.next();
      for (int j = 1; j <= w; j++) {
        m[i][j] = line.charAt(j - 1) == '.';
        if (m[i][j]) {
          numWhite++;
        }
      }
    }

    PriorityQueue<Node> q = new PriorityQueue<Node>();
    q.add(new Node(1, 1, 1));
    boolean[][] visited = new boolean[h+2][w+2];
    while (!q.isEmpty()) {
      Node node = q.poll();
      if (visited[node.i][node.j]) {
        continue;
      }
      if (node.i == h && node.j == w) {
        System.out.println(numWhite - node.step);
        return;
      }
      visited[node.i][node.j] = true;
      for (int k = 0; k < 4; k++) {
        int nextI = node.i + DI[k];
        int nextJ = node.j + DJ[k];
        if (!m[nextI][nextJ] || visited[nextI][nextJ]) {
          continue;
        }
        q.add(new Node(nextI, nextJ, node.step + 1));
      }
    }
    System.out.println(-1);
  }
}
