#t347. 红与黑
红与黑
Red and Black
Problem Background
Special for beginners, ^_^
Problem Description
There is a rectangular room with its floor tiled by red and black square tiles. You stand on one of the black tiles and can only move to adjacent black tiles. Write a program to compute the total number of black tiles you can reach.
Input Format
The input consists of multiple data sets. The first line of each data set contains two integers and , the number of tiles in the and directions, respectively. Both and do not exceed . The following lines each contain characters. Each character represents the color of a tile, according to the following rules:
.: a black tile;#: a white tile;@: a black tile, and you are standing on it. This character appears exactly once in each data set.
When a line containing two zeros is read, the input ends.
Output Format
For each data set, output one line showing the number of tiles you can reach starting from the initial position (counting the initial tile as well).
Sample Input
6 9
....#.
.....#
......
......
......
......
......
#@...#
.#..#.
0 0
Sample Output
45
Constraints
Time limit: 1s, memory limit: 1024KiB for each test case.