#include<iostream>
using namespace std;
#define MAX (256)

char field[MAX][MAX];
int W, H;
int ans = 0;
int sx, sy;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int x, int y){
	if(0 <= x && x < H && 0 <= y && y < W && field[x][y] == '.'){
		ans++;
		field[x][y] = '#';

		for(int i=0; i < 4; i++){
			int nx = x + dx[i]; int ny = y + dy[i];
			dfs(nx, ny);
		}
	}
}

int main(){
	while(cin >> W >> H, W || H){
		ans = 0;
		for(int i=0; i < H; i++){
			for(int j=0; j < W; j++){
				cin >> field[i][j];
				if(field[i][j] == '@'){
					sx = i;
					sy = j;
					field[i][j] = '.';
				}
			}
		}
		dfs(sx, sy);

		cout << ans << endl;
	}

}