#include <stdio.h>

int width,height;
char map[20][21];

int tansaku(int x,int y) {
	int result=1;
	if(x<0 || x>=width || y<0 || y>=height)return 0;
	if(map[y][x]=='#')return 0;
	map[y][x]='#';
	result+=tansaku(x-1,y);
	result+=tansaku(x+1,y);
	result+=tansaku(x,y-1);
	result+=tansaku(x,y+1);
	return result;
}

int main(void) {
	int i,j;
	int sx,sy;
	while(1) {
		scanf("%d%d",&width,&height);
		if(width==0 && height==0)break;
		for(i=0;i<height;i++) {
			scanf("%s",map[i]);
			for(j=0;j<width;j++) {
				if(map[i][j]=='@'){sx=j;sy=i;}
			}
		}
		printf("%d\n",tansaku(sx,sy));
	}
	return 0;
}