#include <stdio.h>

int main(void)
{
	int W, H;
	int map[21][21];
	char in[21];
	int x, y;
	int flag;
	int count;
	
	while (1){
		scanf("%d%d", &W, &H);
		if (W == 0 && H == 0){
			break;
		}
		
		for (y = 1; y <= H; y++){
			scanf("%s", in);
			for (x = 1; x <= W; x++){
				switch (in[x - 1]){
				  case '.':
				    map[y][x] = 0;
					break;
				  
				  case '#':
				    map[y][x] = -1;
					break;

				  case '@':
				    map[y][x] = 1;
					break;
				}
			}
		}
		count = 1;
		do {
			flag = 0;
			for (y = 1; y <= H; y++){
				for (x = 1; x <= W; x++){
					if (map[y][x] == 1){
						if (y - 1 >= 1 && map[y - 1][x] == 0){
							map[y - 1][x] = 1;
							count++;
							flag = 1;
						}
						if (y + 1 <= H && map[y + 1][x] == 0){
							map[y + 1][x] = 1;
							count++;
							flag = 1;
						}
						if (x - 1 >= 1 && map[y][x - 1] == 0){
							map[y][x - 1] = 1;
							count++;
							flag = 1;
						}
						if (x + 1 <= W && map[y][x + 1] == 0){
							map[y][x + 1] = 1;
							count++;
							flag = 1;
						}
					}
				}
			}
		} while (flag == 1);
		
		printf("%d\n", count);
	}
	return (0);
}