#include <stdio.h>

int map[32][32];

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

int count = 0;
int serch(int x, int y)
{
    int i;
    if (map[y][x] == '@' || map[y][x] == '.')
    {
        count++;
        map[y][x] = '#';
        for (i = 0; i < 4; i++)
        {
            serch(x + dx[i], y + dy[i]);
        }
    }
    return 0;
}
int main()
{
    int w, h, i, j, x, y;
    char enter;
    while (1)
    {
        scanf("%d %d", &w, &h);
        scanf("%c", &enter);
        if (w == 0 && h == 0) break;
        for (i = 0; i < 32; i++)
            for (j = 0; j < 32; j++)
                map[i][j] = '#';
        count = 0;
        for (i = 1; i <= h; i++)
        {
            for (j = 1; j <= w; j++)
            {
                scanf("%c", &map[i][j]);
                if (map[i][j] == '@')
                {
                    x = j;
                    y = i;
                }
            }
            scanf("%c", &enter);
        }
        serch(x, y);
        printf("%d\n", count);
    }
    return 0;
}