AdvancedRating 1700
Break the Fewest Walls
Walk from the top-left to the bottom-right cell, moving up, down, left or right. Cells marked # are walls; you may break through walls. Print the fewest walls you must break.
Input
r and c, then r rows of . and #.
Output
One integer.
Sample 1
Input
3 3 .#. ##. .#.
Output
1
Sample 2
Input
1 1 .
Output
0
Output appears here