/*
_...---.._
,' ~~"--..
/ ~"-._
/ ~-.
/ . `-.
\ -.\ `-.
\ ~-. `-.
,-~~\ ~.
/ \ `.
. \ `.
| \ .
| \ \
. `. \
\ \
` `. \
` \. \
` \`. \
. \ -. \
` -. \
. ` - \ .
` \ ~- \
` . ~. \
. \ -_ \
` - \
. | ~. \
` | \ \
. | \ \
` | `. \
` ` \ \
. . `. `.
` : \ `.
\ ` \ `.
\ . `. `~~-.
\ : ` \ \
. . \ : `.\
` : \ | | .
\ . \ | |
\ : \ ` | `
. . | |_ .
` `. ` ` | ~.;
\ `. . . .
. `. ` ` `
`. `._. \ `.\
` < \ `. | .
` ` : ` | |
` \ ` | |
`. | \ : .' |
"Are you crying? " ` | \ `_-' |
"It's only the rain." : | | | : ;
"The rain already stopped."` ; |~-.| : '
"Devils never cry." : \ | ` ,
` \` : '
: \` `_/
` .\ "For we have none. Our enemy shall fall."
` ` \ "As we apprise. To claim our fate."
\ | : "Now and forever. "
\ .' : "We'll be together."
: : "In love and in hate"
| .'
| : "They will see. We'll fight until eternity. "
| ' "Come with me.We'll stand and fight together."
| / "Through our strength We'll make a better day. "
`_.' "Tomorrow we shall never surrender."
sao xin*/
#include <vector>
#include <iostream>
#include <string>
//#include <map>
#include <stack>
#include <cstring>
#include <queue>
#include <list>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>
#include<functional>
#define INF 0xfffffff
#define eps 1e-6
#define LL long long
using namespace std;
const int maxn=1e3+5;
const int maxx=1e4+5;
const double q = (1 + sqrt(5.0)) / 2.0; // 黄金分割数
/*
std::hex <<16进制 cin>>std::hex>>a>>std::hex>>b
cout.setf(ios::uppercase);cout<<std::hex<<c<<endl;
b=b>>1; 除以2 二进制运算
//f[i]=(i-1)*(f[i-1]+f[i-2]); 错排
/ for (int i=1; i<=N; i++)
for (int j=M; j>=1; j--)
{
if (weight[i]<=j)
{
f[j]=max(f[j],f[j-weight[i]]+value[i]);
}
}
priority_queue<int,vector<int>,greater<int> >que3;//注意“>>”会被认为错误,
priority_queue<int,vector<int>,less<int> >que4;最大值优先
//str
//tmp
//vis
//val
//cnt 2486 hdu 3790最短路径
*/
typedef struct node
{
int x,y;
int step;
}N;
int c,r;
bool visited[maxn][maxn];
char mapp[maxn][maxn];
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int step;
int BFS(int sx,int sy)
{
queue<N>Q;
N pre,cur;
pre.x=sx;
pre.y=sy;
pre.step=1;
visited[pre.x][pre.y]=true;
Q.push(pre);
while(!Q.empty())
{
pre=Q.front();
Q.pop();
step++;
for(int i=0;i<4;i++)
{
cur=pre;
cur.x=pre.x+dx[i];
cur.y=pre.y+dy[i];
if(cur.x>=1 && cur.x<=r && cur.y>=1 && cur.y<=c
&& visited[cur.x][cur.y]==false && mapp[cur.x][cur.y]=='.')
{
visited[cur.x][cur.y]=true;
cur.step++;
Q.push(cur);
}
}
}
return step;
}
int main(void)
{
while(scanf("%d%d",&c,&r),r||c)
{
int sx,sy;
for(int i=1;i<=r;i++)
{
scanf("%s",mapp[i]+1);
for(int j=1;j<=c;j++)
{
if(mapp[i][j]=='@')
{
sx=i;
sy=j;
}
}
}
memset(visited,false,sizeof(visited));
step=0;
int ans=BFS(sx,sy);
cout<<ans<<endl;
}
}