T[20][20],X,Y,x,y,p,q,i,c;
#define t T[y][x]
void R(x,y){(0<=x&&x<X&&0<=y&&y<Y&&!t)?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++){
		for(x=i%X,y=i/X;(c=getchar())=='\n';);
		switch(c){
			case'@':p=x;q=y;
			case'.':t=0;break;
			case'#':t=1;
		}
	}
exit(0);}