int w, h;
int map[32][32];

int dx[] = {0, 1, 0 ,-1};
int dy[] = {-1, 0, 1, 0};

int count = 0;

void solve(int x, int y)
{
    int i, nextX, nextY;
    count++;
    map[y][x] = '#';
    for (i = 0; i < 4; i++)
    {
        nextX = x + dx[i];
        nextY = y + dy[i];
        if (0 <= nextX && nextX < w && 0 <= nextY && nextY < h)
        {
            if (map[nextY][nextX] != '#')
                solve(nextX, nextY);
        }
    }
}

int main()
{
    int i, j;
    int x, y;
    while (1)
    {
        scanf("%d %d", &w, &h);
        if (w == 0 && h == 0)
            break;
        for (i = 0; i < h; i++)
        {
            for (j = 0; j < w; j++)
            {
                map[i][j] = getchar();
                if (!(map[i][j] == '.' || map[i][j] == '#' || map[i][j] == '@'))
                {
                    j--;
                    continue;
                }
                if (map[i][j] == '@')
                {
                    x = j;
                    y = i;
                }
            }
        }
        count = 0;
        solve(x, y);
        printf("%d\n", count);
    }
    return 0;
}