#include<stdio.h>
#include<string.h>
char map[25][25];
int n, m, num;
int dr[4] = { -1,1,0,0 };
int dc[4] = { 0,0,1,-1 };
bool path(int r, int c)
{
if (r >= 0 && r <m && c >= 0 && c <n )
return true;
else
return false;
}
void dfs(int r, int c)
{
for (int i = 0; i < 4; i++)
{
int rr = r + dr[i];
int cc = c + dc[i];
if (path(rr, cc) && map[rr][cc] == ‘.‘)
{
map[rr][cc] = ‘#‘; //设置墙
num++;
dfs(rr, cc);
}
}
}
int main()
{
int i, j;
while (scanf("%d %d",&n,&m)!=EOF)
{
if (n == 0 && m == 0)
break;
for (i = 0; i < n; i++)
scanf("%s", map[i]);
num = 1;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
if (map[i][j] == ‘@‘)
{
dfs(i, j);
break;
}
printf("%d\n", num);
}
return 0;
}