#include <iostream>#include <string>#define F(i,a,b) for (int i=a;i<=b;i++)using namespace std;struct Tile{int x, y;Tile() {}Tile(int a, int b) { x = a, y = b; }};int startx, starty, h, w,move[4][2] = { {0, 1}, {1, 0}, {-1, 0}, {0, -1} };bool map[21][21], mk[21][21];Tile Q[402];void bfs(){int now = 1, last = 1;memset(mk , 0, sizeof(mk ) );Q[now] = Tile(startx, starty);mk[startx][starty] = true;while (now <= last){F(i,0,3){int newx = Q[now].x + move[i][0], newy = Q[now].y + move[i][1];if (0<=newx && h > newx && 0 <=newy && w > newy){if (map[newx][newy] && !mk[newx][newy] ){mk[newx][newy] = true;Q[++last] = Tile(newx, newy);}}}now++;}cout << last << endl;}int main(){string str;while (cin >> w >> h && w && h){F(i,0,h-1){cin >> str;F(j,0,w-1){if (str[j] == '.')map[i][j] = true;if (str[j] == '#')map[i][j] = false;if (str[j] == '@'){startx = i, starty = j;map[i][j] = true;}}}bfs();}return 0;}


