Description
Consider a network of N × M grid, each grid is either empty, or an obstacle. The entire grid surrounded by walls (i.e., the first row and the n-th row, first column and the m-th column is the wall), and only two wall openings, representing the start and end. The starting point is always to the left of the grid, the end is always in the right grid. You can only move in four directions: up and down. Data to ensure there is at least one path from start to finish.
From the beginning to the end there may be many paths, find out how many must pass through the mesh grid all paths.
Input
The first line contains two integers N, M, N represents the mesh rows and M columns.
Next N lines of M symbols, represents the grid. '#' Represents a wall or obstacle, '' represents the open space.
Output
Output file contains an integer, by the number of necessary points.
Sample Input
7 7
#######
....#.#
#.#.###
#.....#
###.#.#
#.#....
#######
Sample Output
5
HINT
Sample interpretation
(2, 1) (2, 2) (4, 4) (6, 6) (6, 7)
Data range and Conventions
For 10% of the data, 3≤N, M≤50
For 50% of the data, 3≤N, M≤500
For all the data, 3≤N, M≤1000