#include <stdio.h>
#include <stdlib.h>
#include <math.h>

char map[21][21];
int width, height;
int x, y;

#define fors(i, n) for (int i = 0; i < n; i++)

int parse()
{
	scanf("%d %d", &width, &height);
	if (width == 0 || height == 0)
		return 0;
	fors(i, 21) fors(j, 21) map[i][j] = 'F';
	fors(i, height)
	{
		scanf("%s", map[i]);
		fors(j, width)
		{
			if (map[i][j] == '@')
				x = j, y = i;
		}
	}
	return 1;
}

int dfs(int y, int x)
{
	if (map[y + 1][x] == '.')
		map[y + 1][x] = '@', dfs(y + 1, x);
	if (map[y - 1][x] == '.')
		map[y - 1][x] = '@', dfs(y - 1, x);
	if (map[y][x + 1] == '.')
		map[y][x + 1] = '@', dfs(y, x + 1);
	if (map[y][x - 1] == '.')
		map[y][x - 1] = '@', dfs(y, x - 1);
}

int main()
{
	while (parse())
	{
		int res = 0;
		dfs(y, x);
		fors(i, width)
		{
			fors(j, height)
			{
				if (map[j][i] == '@')
					res++;
			}
		}
		printf("%d\n", res);
	}
}
