T[20][20],X,Y,x,y,p,q,i;
#define t T[y][x]
void R(x,y){(0<=x&&x<X&&0<=y&&y<Y&&(t=1))?t=1,i++,R(x-1,y),R(x+1,y),R(x,y-1),R(x,y+1):0;}
main(){for(;scanf("%d%d",&X,&Y),X;i=0,R(p,q),printf("%d\n",i))
for(i=0;i<X*Y;i++)switch(x=i%X,y=i/X,getchar()){
	case 10:i--;break;
	case'@':p=x;q=y;
	case'.':t=0;break;
	case'#':t=1;
}exit(0);}