Red and Black

No attempts yetTime limit1sMemory limit128 MB

Problem

There is a rectangular room covered with square tiles. Each tile is colored either red or black. A person is standing on a black tile. From the tile they are on, they can move to one of the four adjacent tiles (up, down, left, or right), but they cannot step on red tiles — they can move only onto black tiles.

Write a program that counts how many black tiles the person can reach by repeating these moves.

Input

The input consists of several data sets. Each data set begins with a line containing two positive integers $W$ and $H$, the numbers of tiles in the $x$- and $y$-directions respectively. Both $W$ and $H$ are at most $20$.

The next $H$ lines each contain $W$ characters, where each character describes the color of a tile as follows.

  • . — a black tile
  • # — a red tile
  • @ — the person, standing on a black tile (appears exactly once per data set)

The end of the input is indicated by a line containing two zeros.

Output

For each data set, output on a single line the number of tiles the person can reach from the starting tile, including the starting tile itself.