问题 23748 --The song of Ice and Fire

23748: The song of Ice and Fire

时间限制: 1 Sec  内存限制: 128 MB
提交: 39  解决: 19
[提交][状态][讨论版][数据上传:][下载FPS1元][下载测试数据1元][20kb]

题目描述

    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.

输入

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

提示

来源

[提交][状态]