#include <stdio.h>

char map[32][32];

int black(int y, int x)
{
    if (map[y][x] != '.' && map[y][x] != '@') return 0;
    map[y][x] = '#';
    return black(y - 1, x) + black(y + 1, x) + black(y, x - 1) + black(y, x + 1) + 1;
}

int main(void)
{
    int w, h;

    while (scanf("%d %d", &w, &h), w != 0){
        int i, j;

        for (i = 1; i <= h; i++) scanf("%s", map[i] + 1);
        for (i = 1; i <= h; i++){
            for (j = 1; j <= w; j++){
                if (map[i][j] == '@'){
                    printf("%d\n", black(i, j));
                    i = h, j = w;
                    break;
                }
            }
        }
    }

    return 0;
}