#include<stdio.h>

int main(void){
    int W=0,H=0;
    int ans[100000]={0};
    char board[21][21];
    int quex[100000]={0};
    int quey[100000]={0};
    int count=0;
    int queC=0;
    while(1){
        scanf("%d %d",&W,&H);
        if(W==0&&H==0){
            break;
        }
        for(int i=0;i<H;i++){
            scanf("%s",board[i]);
            for(int j=0;j<W;j++){
                if(board[i][j]=='@'){
                    quex[0]=j;
                    quey[0]=i;
                }
            }
        }
        queC=0;
        while(1){
          
            int sw=0;
            if(quex[queC]!=0){
                if(board[quey[queC]][quex[queC]-1]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1]-1;
                    quey[queC]=quey[queC-1];
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(quex[queC]!=W-1){
                if(board[quey[queC]][quex[queC]+1]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1]+1;
                    quey[queC]=quey[queC-1];
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(quey[queC]!=0){
                if(board[quey[queC]-1][quex[queC]]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1];
                    quey[queC]=quey[queC-1]-1;
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(quey[queC]!=H-1){
                if(board[quey[queC]+1][quex[queC]]=='.'){
                    queC+=1;
                    quex[queC]=quex[queC-1];
                    quey[queC]=quey[queC-1]+1;
                    board[quey[queC]][quex[queC]]='#';
                    ans[count]++;
                    sw=1;
                }
            }
            if(sw==0){
                queC-=1;
            }
           
            if(queC<0){
                ans[count]+=1;
                break;
            }
        }
        count++;
    }
    for(int i=0;i<count;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}
