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

#define MAX_SIZE 20

int w, h;
char field[MAX_SIZE][MAX_SIZE + 1];

int out(int x, int y) {
	return x < 0 || y < 0 || x >= w || y >= h;
}

int dfs(int x, int y) {
	static const int dx[] = {1, 0, -1, 0};
	static const int dy[] = {0, 1, 0, -1};

	int count = 1;
	field[y][x] = '#';

	for(int dir = 0; dir < 4; ++dir) {
		const int nx = x + dx[dir];
		const int ny = y + dy[dir];

		if(out(nx, ny) || field[ny][nx] == '#') continue;
		count += dfs(nx, ny);
	}

	return count;
}

int main() {
	while(scanf("%d %d", &w, &h) == 2 && w) {
		int x, y;
		int sx, sy;

		for(y = 0; y < h; ++y) {
			scanf("%s", field[y]);

			for(x = 0; x < w; ++x) {
				if(field[y][x] == '@') {
					sx = x;
					sy = y;
					break;
				}
			}
		}

		printf("%d\n", dfs(sx, sy));
	}

	return EXIT_SUCCESS;
}