#include<stdio.h>
char map[20][21];
char count[20][20];
int s1, s2;
void solve(int y, int x) {
	if (!count[y][x]) {
		if (map[y][x] == '.' || map[y][x] == '@') {
			count[y][x] = 1;
			if (y < s2 - 1) solve(y + 1, x);
			if (y > 0) solve(y - 1, x);
			if (x < s1 - 1) solve(y, x + 1);
			if (x > 0) solve(y, x - 1);
		}
	}
}
int main() {
	int i, j, ans, point[2];
	while (1) {
		scanf("%d %d", &s1, &s2);
		if (!(s1||s2)) break;
		for (i = 0; i < s2; i ++) scanf("%s", map[i]);
		for (i = 0; i < s2; i ++) for (j = 0; j < s1; j ++) if (map[i][j] == '@') {
			point[0] = i; point[1] = j;
		}
		for (i = 0; i < 20; i ++) for (j = 0; j < 20; j ++) count[i][j] = 0;
		ans = 0;
		solve(point[0], point[1]);
		for (i = 0; i < s2; i ++) for (j = 0; j < s1; j ++) ans += count[i][j];
		printf("%d\n", ans);
	}
	return 0;
}