#include <stdio.h>
int map[22][22];
int w, h;
int v;

int main(void){
	int i, x, y;
	
	scanf("%d %d", &w, &h);
	while(w && h){
		for(i=0; i<w*h; i++){
			switch (getchar()){
			case 10:
				i--;
				break;
			case '.':
				map[i%w + 1][i/w + 1] = 1;
				break;
			case '#':
				map[i%w + 1][i/w + 1] = 0;
				break;
			case '@':
				map[x = i%w + 1][y = i/w + 1] = 1;
				break;
			}
		}
		v = 0;
		searching(x, y);
		printf("%d\n", v);
		scanf("%d %d", &w, &h);
	}
	
	return 0;
}

int searching(int X, int Y){
	if(map[X][Y] == 1){
		map[X][Y] = 2;
		v++;
		if(X>0) searching(X-1, Y);
		if(X<w) searching(X+1, Y);
		if(Y>0) searching(X, Y-1);
		if(Y<h) searching(X, Y+1);
	}
	return 0;
}