Neo is trying to escape from Agent Smith and his copies. He is currently at the top left corner of the Matrix and has to reach the bottom right corner as fast as possible. Neo can only run down or to the right, else Agent Smith will have time to catch him. In addition, some of the cells of the Matrix are blocked.
To confuse Agent Smith, Neo has gained the ability to create virtual copies of himself. Neo can create one virtual copy of himself for each distinct path through the Matrix. Help Neo compute how many virtual copies he needs to create.
The input consists of several test cases. Each test case starts with
the number of rows
and the number of columns
of the Matrix. This is followed by
rows with
characters each. The character "." indicates a free cell of
the Matrix, while "#" indicates a blocked cell. The top
left and bottom right corners are always free.
For each test case, a number on a single line indicating the number of virtual copies Neo needs to create.
Input
3 3 ... ... ...
Output
6
Input
4 4 ..#. #..# .#.. ..#.
Output
1
Input
2 3 ..# .#.
Output
0