Chocolate
Marichka and Zenik have a rectangular tile of delicious Ukrainian chocolate. The tile consists of the same squares, each of which can be either black or white.
Marichka will draw an arbitrary (possibly zero) number of full horizontal (from left to right) tile sections, while Zenik will draw an arbitrary (possibly zero) number of full vertical (top to bottom) sections. Note that cuts can only be made between the squares of the tile, and Zenik and Marichka can make a different number of cuts. After all the cuts, the tile will fall into a certain number of rectangular pieces, which our heroes will divide among themselves in a certain way.
Since Zenik is very fond of dark chocolate, he wants after all cuts the number of whole pieces, which consist exclusively of black squares, be as large as possible. Marichka wants to make the same amount as small as possible. Note that the heroes are not interested in what size the pieces will be: the main thing is their number.
In order to be honest, Andrei will separately and independently ask Marichka and Zenik in which exact places to cut, and then he will make these cuts.
Write a program that, according to the given tile size, as well as the type of each unit square, will determine how many pieces are formed after all cuts, consisting solely of black squares, under the condition of optimal actions of both heroes.
Input
First line contains two integers n and m (2 ≤ n ≤ 1000, 2 ≤ m ≤ 1000): the height and the width of the tile respectively. Next given n lines of m characters each, which indicate the type of corresponding unit chocolate bar. Symbol B means a black square, symbol W means white.
Output
Print the number of pieces that will consist exclusively of squares of dark chocolate.