
#include <bits/stdc++.h>
using namespace std;
int w, h;
int sx, sy;
char a[25][25];
bool f[25][25];
int ans;
int t[410][2], head, tail;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
void bfs(int x, int y){
	head = 0;
	tail = 1;
	t[1][0] = x;
	t[1][1] = y;
	while(head < tail){
		head++;
		for(int i = 0;i < 4;i++){
			int xx = t[head][0] + dx[i];
			int yy = t[head][1] + dy[i];
			if(xx >= 1 && xx <= w && yy >= 1 && yy <= h && a[xx][yy] == '.' && f[xx][yy] == 0){
				ans++;
				f[xx][yy] = 1;
				tail++;
				t[tail][0] = xx;
				t[tail][1] = yy;
			}
		}
	}
}
int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) return 0;
		for(int i = 1;i <= h;i++){
			for(int j = 1;j <= w;j++){
				cin >> a[i][j];
				if(a[i][j] == '@'){
					sx = i;
					sy = j;
				}
			}
		}
		memset(f, 0, sizeof(f));
		ans = 1;
		f[sx][sy] = 1;
		bfs(sx, sy);
		cout << ans << endl;
	}
	return 0;
}
不知道怎么错的,求指教