#include<iostream> #include<cstdio> #include<queue> #include<algorithm> #include<cstring> using namespace std; #define MAXN 21 struct node { int x; int y; }; int n,m,g[MAXN][MAXN]; bool vis[MAXN][MAXN]; int x[4]={1,-1,0,0}; int y[4]={0,0,1,-1}; int bfs(int sx,int sy) { int ans = 0; node temp; temp.x = sx; temp.y = sy; vis[sx][sy] = true; queue<node> q; q.push(temp); while(!q.empty()) { temp = q.front(); q.pop(); //cout<<temp.x<<' '<<temp.y<<endl; ans++; for(int i=0;i<4;i++) { int tx = temp.x + x[i]; int ty = temp.y + y[i]; if((tx>=0&&ty>=0&&tx<m&&ty<n)&&!vis[tx][ty]&&g[tx][ty]=='.') { vis[tx][ty] = true; node nn; nn.x = tx; nn.y = ty; q.push(nn); } } } return ans; } int main() { while(scanf("%d%d",&n,&m)) { getchar(); if(n+m==0) break; int sx,sy; memset(g,0,sizeof(g)); memset(vis,false,sizeof(vis)); for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { scanf("%c",&g[i][j]); if(g[i][j]=='@') { sx = i; sy = j; } } getchar(); } cout<<bfs(sx,sy)<<endl; } return 0; }