#include <stdio.h>

#define MAPX 25
#define MAPY 25

char data[MAPY][MAPX];
int h,w;

int search(int num, int nowx, int nowy){
	num = 1;
	data[nowy][nowx] = '#';
	if(nowx>0)if(data[nowy][nowx-1]=='.')num += search(num, nowx-1, nowy);
	if(nowy>0)if(data[nowy-1][nowx]=='.')num += search(num, nowx, nowy-1);
	if(nowx<w-1)if(data[nowy][nowx+1]=='.')num += search(num, nowx+1, nowy);
	if(nowy<h-1)if(data[nowy+1][nowx]=='.')num += search(num, nowx, nowy+1);
	return num;
}

void solve(){
	int i,t;
	int sx,sy;
	for(i = 0;i < h;i++){
		scanf("%s", &data[i][0]);
	}
	for(i = 0;i < h;i++){
		for(t = 0;t < w;t++){
			if(data[i][t]=='@'){
				sx = t;
				sy = i;
			}
		}
	}
	printf("%d\n", search(0,  sx, sy));
}

int main(){
	while(1){
		scanf("%d %d ", &w, &h);
		if(h == 0 && w == 0)break;
		solve(h,w);
	}
	return 0;
}