#include <stdio.h>
#include <stdlib.h>

typedef struct{
	int x;
	int y;
} point;

int tile[20][20];
point stack[400];
int sp=0;

void stack_push(point i){
	stack[sp++]=i;
}

point stack_pop(){
	return stack[--sp];
}

int stack_empty(){
	return !sp;
}

int main()
{
    int i,j,w,h;
    point human;


    while(1){
		for(i=0;i<20;i++)
			for(j=0;j<20;j++)
				tile[i][j]='#';

		scanf("%d %d",&w,&h);
		if(w==0 && h==0)
			break;

		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				retry:
				tile[j][i]=getchar();
				if(tile[j][i]!='@' && tile[j][i]!='.' && tile[j][i]!='#')
					goto retry;
				if(tile[j][i]=='@'){
					human.x=j; human.y=i;
				}
			}
		}

		stack_push(human);
		tile[human.x][human.y]='#';

		int count=0;

		while(!stack_empty()){
			point current=stack_pop();
			point temp;

			count++;

			if(current.x+1<20 && tile[current.x+1][current.y]=='.'){
				tile[current.x+1][current.y]='#';
				temp.x=current.x+1; temp.y=current.y;
				stack_push(temp);
			}
			if(current.x-1>=0 && tile[current.x-1][current.y]=='.'){
				tile[current.x-1][current.y]='#';
				temp.x=current.x-1; temp.y=current.y;
				stack_push(temp);
			}
			if(current.y+1<20 && tile[current.x][current.y+1]=='.'){
				tile[current.x][current.y+1]='#';
				temp.x=current.x; temp.y=current.y+1;
				stack_push(temp);
			}
			if(current.y-1>=0 && tile[current.x][current.y-1]=='.'){
				tile[current.x][current.y-1]='#';
				temp.x=current.x; temp.y=current.y-1;
				stack_push(temp);
			}
		}


		printf("%d\n",count);
    }

    return 0;
}