#667. The song of Ice and Fire
The song of Ice and Fire
说明
House Lannister of Casterly Rock is one of the Great Houses of Seven Kingdoms, and the principal house of the Westerlands. Their seat is Casterly Rock, though another branch exists that is based in nearby Lannisport. Their sigil is a golden lion on a field of crimson.Their official motto is "Hear Me Roar!" However, their unofficial motto, equally well known, is "A Lannister always pays his debts."The Warden of the West is traditionally a Lannister
The gold of Casterly Rock,Castamere, the Pendric Hills and the Golden Tooth has made them the wealthiest of the Great Houses, the keep at Casterly Rock sits literally on top of a gold mine, built into the very rock. From that lofty yet uncomfortable position, House Lannister rules over the Westerlands and influences all of Westeros, by virtue of the kingdom’s purse strings.
One day, Tyrion Lannister come to his gold mine field,which is a large rectangular in the land.If the two gold deposits are adjacent, then it will be one mineral resources. Your tesk is tell him how many mineral resources are contained in this land.
</span>输入格式
The input consists of serveral test cases. For each case contains two positive integer N and M(1 <= M , N <= 100), If N = 0 it means the end of the input; Each of the following N lines contain M characters. Each character is '$' or '#' reflect that there is gold or not.
输出格式
For each test case, print the number of mineral resources ,and one line one case.
3 4
##$$
$##$
##$#
1 5
###$$
2 2
##
##
0 0
2
1
0