#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int atinclease_count=0,h,w,i,j,atcount=0;
    char table[21][21];
    while (1) {
        
        scanf("%d %d ",&w,&h);
        
        if (h==0 && w==0) {
            break;
        }
        
        for (i=0; i<h; i++) {
                //table[i][j] = getchar();
                scanf("%s",table[i]);
        }
        
        while (1) {
            
            for (i=0; i<h; i++) {
                for (j=0; j<w; j++) {
                    if (table[i][j] == '@') {
                        if (table[i-1][j]=='.') {
                            table[i-1][j] = '@';
                            atinclease_count++;
                        }
                        
                        if (table[i+1][j]=='.') {
                            table[i+1][j] = '@';
                            atinclease_count++;
                        }
                        
                        if (table[i][j-1]=='.') {
                            table[i][j-1] = '@';
                            atinclease_count++;
                        }
                        
                        if (table[i][j+1]=='.') {
                            table[i][j+1] = '@';
                            atinclease_count++;
                        }
                    }
                }
            }
            
            if(atinclease_count == 0){
                break;
            }
            
            atinclease_count=0;
            
        }
        
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                if (table[i][j]=='@') {
                    atcount++;
                }
            }
        }
        
        printf("%d\n",atcount);
        atcount=0;
    }
    return 0;
}