#include <stdio.h>

char room[22][22];
int dir_x[] = {0, 1, 0, -1};
int dir_y[] = {-1, 0, 1, 0};

int visit(int x, int y)
{
    int ret = 1;
    room[y][x] = '#';
    int i;
    for(i = 0 ; i < 4; i++){
        if(room[y + dir_y[i]][x + dir_x[i]] != '#')
            ret += visit(x + dir_x[i], y + dir_y[i]);
    }
    return ret;
}

int W, H;

int main(void)
{
    while(1){
        scanf("%d %d", &W, &H);
        if(W == 0 && H == 0)
            break;
        int i, j;

        int x, y;
        for(i = 1; i <= H; i++){
            scanf("%s", &(room[i][1]));
        }
        for(i = 0; i <= H + 1; i++){
            for(j = 0; j <= W + 1; j++){
                if(i == 0 || i == H + 1 || j == 0 || j == W + 1)
                    room[i][j] = '#';
                if(room[i][j] == '@'){
                    x = j;
                    y = i;
                }
            }
        }

        printf("%d\n", visit(x, y));
    }

    return 0;
}