#include <stdio.h>
#include <string.h>

char map[30][30];
int x, y;
int num;

int dfs(int sy, int sx)
{
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int i;
    num++;
    map[sy][sx] = 'x';
    
    for (i = 0; i < 4; i++){
        if (0 <= sx + dx[i] && sx + dx[i] < x && 0 <= sy + dy[i] && sy + dy[i] < y && map[sy + dy[i]][sx + dx[i]] == '.'){
            dfs(sy + dy[i], sx + dx[i]);
        }
    }
    
    return (num);
}

int main(void)
{
    int i, j;
    int sy, sx;
    
    while (1){
        scanf("%d%d", &x, &y);
        
        if (!(x + y)){
            break;
        }
        getchar();
        for (i = 0; i < y; i++){
            for (j = 0; j < x; j++){
                scanf("%c", &map[i][j]);
                if (map[i][j] == '@'){
                    sy = i;
                    sx = j;
                }
            }
            getchar();
        }
        
        num = 0;
        printf("%d\n", dfs(sy, sx));
    }
    
    return (0);
}