#include<bits/stdc++.h>

using namespace std;

char a[110][110];
int m, n;
int dir[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
int dfs(int x, int y)
{
    if(a[x][y] == '#' || x < 1 || x > n || y < 1 || y > m)
        return 0;
     else
     {
         a[x][y] = '#';
         return dfs(x+1, y) + dfs(x-1, y) + dfs(x, y+1) + dfs(x, y-1) + 1;
     }
}
int main ()
{
    while(cin>>m>>n,m)
    {
        int i, j;
        for(i = 1; i <= n; i++)
            for(j = 1; j <= m; j++)
                cin >> a[i][j];
        int cnt;
        for(i = 1; i <= n; i++)
            for(j = 1; j <= m; j++)
            {
                if(a[i][j] == '@')
                   cnt = dfs(i, j);
            }
        cout << cnt << endl;
    }
    return 0;
}