文件目录

#include <bits/stdc++.h>
using namespace std;
int w, h, x, y, ans = 0;
string mg[105];
bool vis[105][105];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
void dfs(int x, int y)
{
    for (int i = 0; i < 4; i++)
    {
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if (xx >= 0 && xx < h && yy >= 0 && yy < w && !vis[xx][yy] && mg[xx][yy] != '#')
        {
            vis[xx][yy] = true;
            ans++;
            dfs(xx, yy);
        }
    }
}
int main()
{
    while (cin >> w >> h)
    {
        if (w == 0 && h == 0)
            break;
        for (int i = 0; i < h; i++)
        {
            cin >> mg[i];
            if (mg[i].find('@') != string::npos)
            {
                x = i;
                y = mg[i].find('@');
            }
        }
        ans = 1;
        vis[x][y] = true;
        dfs(x, y);
        cout << ans << endl;
        memset(vis, 0, sizeof(vis));
    }
    return 0;
}