1671 - Maze

Time Limit : 1 Second

Memory Limit : 512 MB

Submission: 99

Solved: 15

Description

There is a maze and it has some obstacles inside. 


The maze consists of n*m grids. Each grid is either ‘.’ ( means no obstacle) or ‘b’(means obstacle).


Your dog now need to go through this maze(the beginning at the top left and the the exit at right bottom), but your dog is too stupid like your roommate, so it can only repeat two operations alternatively


1.Keep moving to the right until it can not move


2.Keep moving to the bottom until it can not move


You dog will move to the right first.


You can change a grid from empty to blocked and vice versa. So as not to arouse suspision, you want to change as few grids as possible. What is the mininum number?

Input

The input contains several test cases.


The first line of each test case contains two integers n and m meaning that is a n * m maze. (1 <= n,m<=1000)


From line 2 to line n + 1 of each test case is the n * m maze

Output

For each case, only one integer representing the minimum number.

sample input
5 7
...bb..
.......
....b..
..bb...
bbbbbbb
sample output
2
hint
source
zj
© 2015 HUST ACMICPC TEAM. All Right Reserved.