#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int dir[][2] = {{0,1},{0,-1},{1,0},{-1,0}};
int n,m;
const int N = 21;
char path[N][N];
bool st[N][N];
int dfs(int x,int y)
{
int ans = 1;
path[x][y] = '#';
for(int i = 0; i < 4; i ++)
{
int nx = x + dir[i][0];
int ny = y + dir[i][1];
if(nx >= 0 && nx < n && ny >= 0 && ny < m && path[nx][ny] == '.')
{
ans += dfs(nx,ny);
}
}
return ans;
}
int main()
{
while(cin >> m >> n, n || m)
{
for(int i = 0; i < n; i ++) cin >> path[i];
int dx,dy;
for(int i = 0; i < n; i ++)
for(int j = 0; j < m; j ++)
if(path[i][j] =='@')
dx = i,dy = j;
printf("%d\n",dfs(dx,dy));
}
return 0;
}