#C1800. Taco Adventure: Count Valid Paths

    ID: 45046 Type: Default 1000ms 256MiB

Taco Adventure: Count Valid Paths

Taco Adventure: Count Valid Paths

You are tasked with creating a function to help a game character navigate a grid. The grid is represented by n rows and m columns. Each cell in the grid is either empty (represented by a '.') or contains an obstacle (represented by a '#'). The player starts at the top-left corner of the grid (cell (0, 0)) and needs to reach the bottom-right corner (cell (n-1, m-1)).

The player can only move in two directions: right or down. Your task is to compute the number of distinct paths from the start to the finish that do not cross any obstacles. If the starting cell is an obstacle, then there is no valid path. Similarly, if no path exists due to obstacles, return 0.

Note: The result should count all valid paths under the movement constraints. Use stdin for input and stdout for output.

inputFormat

The first line contains two integers n and m separated by a space, representing the number of rows and columns respectively. The following n lines each contain a string of length m consisting of the characters '.' (empty cell) and '#' (obstacle), representing the grid.

Example:

3 3
... 
.#. 
... 

outputFormat

Output a single integer representing the number of distinct valid paths from the top-left cell to the bottom-right cell.

## sample
3 3
...
.#.
...
2

</p>