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.util.*;
import java.util.stream.*;

class Main {
  
  static int H,W;
  static String[][] map;
  static int[][] breadth;
  static Deque<Integer[]> que;
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    H = sc.nextInt();
    W = sc.nextInt();
    map = new String[H][W];
    breadth = new int[H][W];
    que = new ArrayDeque<>();
    for (int i = 0; i < H; i++) map[i] = sc.next().split("");
    que.add(new Integer[]{0, 0});
    int b = 1;
    breadth[0][0] = b;
    while (!que.isEmpty()) {
      int n = que.size();
      b++;
      for (int i = 0; i < n; i++) {
        Integer[] p = que.poll();
        search(b, p[0]-1, p[1]);
        search(b, p[0], p[1]+1);
        search(b, p[0], p[1]-1);
        search(b, p[0]+1, p[1]);
      }
    }
    long wallNum = Arrays.stream(map).flatMap(e -> Arrays.stream(e))
      .filter(e -> e.equals("#"))
      .count();
    System.out.println(breadth[H-1][W-1] == 0 ? -1 : H*W-wallNum-breadth[H-1][W-1]);
    //for (int i = 0; i < H; i++) System.out.println(Arrays.toString(breadth[i]));
  }
  
  static void search(int b, int h, int w) {
    if (h < 0 | h >= H | w < 0 | w >= W) return;
    if (map[h][w].equals("#")) return;
    if (breadth[h][w] != 0) return;
    breadth[h][w] = b;
    que.add(new Integer[]{h, w});
  }
}