#include <bits/stdc++.h>
using namespace std;
int w,h;
int cnt;
char a[21][21];
struct point{
int x;
int y;
};
point a1;
bool in(point t){
if(t.x>=0&&t.x<h&&t.y>=0&&t.y<w){
return true;
}
else{
return false;
}
}
int dir[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
bool vis[21][21];
void dfs(point a1){
point t;
for(int i=0;i<4;i++){
t.x=a1.x+dir[i][0];
t.y=a1.y+dir[i][1];
if(!in(t)){
continue;
}
if(!vis[t.x][t.y]&&a[t.x][t.y]=='.'){
cnt++;
vis[t.x][t.y]=true;
dfs(t);
}
}
// if(n==0){
// return;
// }
}
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv)
{
memset(vis,0,sizeof(vis));
cin>>w>>h;
while(w!=0&&h!=0){
cnt=1;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
cin>>a[i][j];
vis[i][j]=false;
if(a[i][j]=='@'){
a1.x=i;
a1.y=j;
}
}
}
dfs(a1);
cout<<cnt;
cout<<endl;
cin>>w>>h;
}
return 0;
}