#include char table[100][100]; using namespace std; int f(int w, int h, int x, int y){ int ret = 0; if(x < 0 || y < 0 || x >= w || y >= h){ return 0; } if(table[y][x] == '#'){ return 0; } ret = 1; table[y][x] = '#'; ret += f(w, h, x, y + 1); ret += f(w, h, x, y - 1); ret += f(w, h, x - 1, y); ret += f(w, h, x + 1, y); return ret; } int main(){ while(true){ int startX, startY; int width, height; cin >> width >> height; if(width == 0 && height == 0){ break; } for(int i = 0; i < height; i++){ for(int j = 0; j < width; j++){ cin >> table[i][j]; if(table[i][j] == '@'){ //cout << "startX = " << j << " startY = " << i << endl; startX = j; startY = i; table[i][j] = '.'; } } } cout << f(width, height, startX, startY) << endl; } }