#include<stdio.h>
int w,h;
char array[21][21];
int search(int x,int y)
{
		if(x<0||y<0||x>=w||y>=h)
			return 0;
		if(array[x][y]=='#')
			return 0;
		else{
				array[x][y]='#';
				return 1+search(x-1,y)+search(x+1,y)+search(x,y-1)+search(x,y+1);
		}
}
			
int main()
{
		int i,j;
		while(scanf("%d%d",&h,&w)&&w!=0&&h!=0){
				for(i=0;i<w;i++)
					scanf("%s",array[i]);
				for(i=0;i<w;i++)
					for(j=0;j<h;j++){
								if(array[i][j]=='@')
									printf("%d\n",search(i,j));
								}
						}
				}


