#include #define N (20) #define BLACK (0) #define RED (-1) using namespace std; const int dx[] = { +1, 0, -1, 0 }; const int dy[] = { 0, +1, 0, -1 }; int main(void) { int m[N][N]; int w, h; while(cin >> w >> h) { if(w == 0 && h == 0) break; for(int j = 0; j < h; j++) { for(int i = 0; i < w; i++) { char c; cin >> c; m[i][j] = (c == '#') ? RED : BLACK; if(c == '@') m[i][j] = 1; } } int sol = 1; int n = 1; bool flag = true; while(flag) { flag = false; for(int j = 0; j < h; j++) { for(int i = 0; i < w; i++) { if(m[i][j] != n) continue; for(int dir = 0; dir < 4; dir++) { int x = i + dx[dir]; int y = j + dy[dir]; if(x < 0 || x >= w || y < 0 || y >= h) continue; if(m[x][y] != BLACK) continue; m[x][y] = n; ++sol; flag = true; } } } } cout << sol << endl; } return 0; }